<!-- 29609-2011 YM modification des adresses d'accès aux référentiel 
 15122014 Prise en compte du référentiel des appellations de taxons--><axsl:stylesheet xmlns:xx="http://xml.sandre.eaufrance.fr/scenario/quesu/3" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sch="http://www.ascc.net/xml/schematron" xmlns:sa_ref="http://xml.sandre.eaufrance.fr/scenario/referentiel/2" xmlns:sa_ref31="http://xml.sandre.eaufrance.fr/scenario/referentiel/3.1" xmlns:axsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
    <axsl:output method="text" omit-xml-declaration="no" standalone="yes" indent="yes"/>
    <!--<axsl:variable name="chemin">http://195.220.97.105:8080/exist/xmldb/db/sandre/Referentiels/old_referentiel.xml</axsl:variable>-->
    <axsl:variable name="cheminPAR">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/PAR.xml</axsl:variable>
    <axsl:variable name="cheminMET">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/MET.xml</axsl:variable>
    <axsl:variable name="cheminSUP">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/SUP.xml</axsl:variable>
    <axsl:variable name="cheminFAN">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/FAN.xml</axsl:variable>
    <axsl:variable name="cheminURF">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/URF.xml</axsl:variable>
    <!--<axsl:variable name="cheminTAX">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/TAX_simplifie.xml</axsl:variable>-->
    <axsl:variable name="cheminAPT">http://xml.sandre.eaufrance.fr/exist/sandre/Referentiels/3.1/APT.xml</axsl:variable>
    <axsl:variable name="testAPT">
        <axsl:for-each select="document($cheminAPT)//sa_ref31:Referentiel/sa_ref31:AppelTaxon">
            <axsl:text>'</axsl:text>
            <axsl:value-of select="./sa_ref31:CdAppelTaxon/text()"/>
            <axsl:text>-</axsl:text>
            <axsl:value-of select="./sa_ref31:StAppelTaxon/text()"/>
            <axsl:text>'</axsl:text>
            <axsl:if test="position()!=last()">
                <axsl:text>, </axsl:text>
            </axsl:if>
        </axsl:for-each>
    </axsl:variable>
    <axsl:template match="*|@*" mode="schematron-get-full-path">
        <axsl:apply-templates select="parent::*" mode="schematron-get-full-path"/>
        <axsl:text>/</axsl:text>
        <axsl:if test="count(. | ../@*) = count(../@*)">@</axsl:if>
        <axsl:value-of select="name()"/>
        <axsl:text>[</axsl:text>
        <axsl:value-of select="1+count(preceding-sibling::*[name()=name(current())])"/>
        <axsl:text>]</axsl:text>
    </axsl:template>
    <axsl:template match="/">
        <axsl:apply-templates select="/" mode="M1"/>
    </axsl:template>
    <axsl:template match="//*[name()='CdParametre']" priority="4000" mode="M1">
        <axsl:choose>
            <axsl:when test="./text()=document($cheminPAR)//sa_ref:Referentiel/sa_ref:Parametre/sa_ref:CdParametre/text()"/>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des paramètres#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <axsl:template match="//*[name()='CdAppelTaxon']" priority="4000" mode="M1">
        <axsl:variable name="valueTestAPT">
            <axsl:text>'</axsl:text>
            <axsl:value-of select="current()"/>
            <axsl:text>-Validé'</axsl:text>
        </axsl:variable>
        <axsl:variable name="valueTestAPTGelé">
            <axsl:text>'</axsl:text>
            <axsl:value-of select="current()"/>
            <axsl:text>-Gelé'</axsl:text>
        </axsl:variable>
        <axsl:choose>
            <axsl:when test="contains($testAPT, $valueTestAPT)"/>
            <axsl:otherwise>
                <axsl:choose>
                    <axsl:when test="contains($testAPT, $valueTestAPTGelé)">A3.2/Le code '<axsl:value-of select="text()"/>' est gelé au regard de la liste de référence des appellations de taxons.#
	</axsl:when>
                    <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des appellations de taxons.#
	</axsl:otherwise>
                </axsl:choose>
            </axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <!--<axsl:template match="//*[name()='CdTaxon']" mode="M1">
        <axsl:choose>
            <axsl:when test="document($cheminAPT)//sa_ref31:Referentiel/AppelTaxon[(./CdAppelTaxon/text()=current())]">
                <axsl:if test="document($cheminAPT)//sa_ref31:Referentiel/AppelTaxon[(./CdAppelTaxon/text()=current())]/StAppelTaxon='Gelé'">
                A3.2/Le code '<axsl:value-of select="text()"/>' est gelé au regard de la liste de référence des appellations de taxons#
            </axsl:if>
            </axsl:when>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des appellations de taxons#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>-->
    <axsl:template match="*[local-name()='CdMethode']" priority="3999" mode="M1">
        <axsl:choose>
            <axsl:when test="document($cheminMET)//sa_ref:Referentiel[./sa_ref:Methode/sa_ref:CdMethode/text()=current()]"/>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des méthodes#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <axsl:template match="*[name()='CdSupport']" priority="3998" mode="M1">
        <axsl:choose>
            <axsl:when test="document($cheminSUP)//sa_ref:Referentiel[./sa_ref:Support/sa_ref:CdSupport/text()=current()]"/>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des supports#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <axsl:template match="*[local-name()='CdUniteReference']" priority="3997" mode="M1">
        <axsl:choose>
            <axsl:when test="document($cheminURF)//sa_ref:Referentiel[./sa_ref:UniteReference/sa_ref:CdUniteReference/text()=current()] or current()=''"/>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des unités de mesure#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <axsl:template match="*[local-name()='CdFractionAnalysee']" priority="3996" mode="M1">
        <axsl:choose>
            <axsl:when test="document($cheminFAN)//sa_ref:Referentiel[./sa_ref:FractionAnalysee/sa_ref:CdFractionAnalysee/text()=current()]"/>
            <axsl:otherwise>E3.1/Le code '<axsl:value-of select="text()"/>' est inconnu au regard de la liste de référence des fractions analysées#</axsl:otherwise>
        </axsl:choose>
        <axsl:apply-templates mode="M1"/>
    </axsl:template>
    <axsl:template match="text()" priority="-1" mode="M1"/>
    <axsl:template match="text()" priority="-1"/>
</axsl:stylesheet>