<xsl:stylesheet xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xalan="http://xml.apache.org/xalan" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:svg="urn:oasis:names:tc:opendocument:xmlns:svg-compatible:1.0" xmlns:draw="urn:oasis:names:tc:opendocument:xmlns:drawing:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.0">
    <xsl:param name="imagesNb"/>
    <xsl:param name="imagePrefixURL"/>
	
	<!-- URL du fichier source Schema du dictionnaire -->
    <xsl:param name="sourceURL"/>
	
	<!--  REST URI pour exploiter les chemins relatifs dans les schemas importes -->
    <xsl:param name="dburi"/>
    <xsl:include href="common.xsl"/>
    <xsl:include href="datadictionaryODF.xsl"/>
    <xsl:output method="xml" encoding="UTF-8" omit-xml-declaration="yes"/>
    <xsl:variable name="targetNamespaceName" select="/*[local-name()='schema']/@targetNamespace"/>
    <xsl:variable name="currentPrefix" select="local-name(/*[local-name()='schema']/namespace::*[.=$targetNamespaceName])"/>
    <xsl:variable name="schemaFileName">
        <xsl:call-template name="getFileName">
            <xsl:with-param name="path" select="$sourceURL"/>
        </xsl:call-template>
    </xsl:variable>
    <xsl:variable name="schemaFilePath">
        <xsl:value-of select="concat($dburi, substring-before( substring-after($sourceURL, '/db'), $schemaFileName))"/>
    </xsl:variable>
    <xsl:variable name="importDocsTmp">
        <xsl:for-each select="//*[local-name()='import']">
            <xsl:variable name="relativeFileName" select="@schemaLocation"/>
            <xsl:variable name="fileName">
                <xsl:call-template name="getFileName">
                    <xsl:with-param name="path" select="@schemaLocation"/>
                </xsl:call-template>
            </xsl:variable>
<!--
			<xsl:message>importDocsTmp:<xsl:value-of select="$fileName"/></xsl:message>
			<xsl:message>OLD VALUE:<xsl:value-of select="concat(@namespace, '/', $fileName)"/></xsl:message>
			<xsl:message>NEW VALUE:<xsl:value-of select="concat($schemaFilePath, $relativeFileName)"/></xsl:message>
-->
			<!-- <xsl:value-of select="concat(@namespace, '/', $fileName)"/> -->
            <url>
                <xsl:value-of select="concat($schemaFilePath, $relativeFileName)"/>
            </url>
        </xsl:for-each>
    </xsl:variable>
    <xsl:variable name="importDocs" select="document(xalan:nodeset($importDocsTmp)/url)"/>
    <xsl:key name="entiteKey" match="//*[local-name()='complexType'][child::*[local-name()='sequence']]" use="@name"/>
    <xsl:key name="attributKey" match="//*[local-name()='complexType'][not(child::*[local-name()='sequence'])]" use="@name"/>
    <xsl:key name="infoKey11" match="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element'][(not(@minOccurs) or @minOccurs=1) and (not(@maxOccurs) or @maxOccurs=1)]" use="@name"/>
    <xsl:key name="infoKey01" match="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element'][@minOccurs=0 and (not(@maxOccurs) or @maxOccurs=1)]" use="@name"/>
    <xsl:key name="infoKey0n" match="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element'][@minOccurs=0 and @maxOccurs='unbounded']" use="@name"/>
    <xsl:key name="infoKey" match="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element']" use="substring-after(@type, ':')"/>
    <xsl:template match="/">
        <xsl:choose>
            <xsl:when test="function-available('xalan:nodeset')"/>
            <xsl:otherwise>
                <!--<xsl:message terminate="yes">ERROR: Function not found: nodeset</xsl:message>-->
            </xsl:otherwise>
        </xsl:choose>
        <root>
            <xsl:call-template name="displayLog">
                <xsl:with-param name="logContent">Début du traitement du dictionnaire des données</xsl:with-param>
            </xsl:call-template>

			<!--
				AFFICHE LES SCHEMAS IMPORTES
			-->
            <xsl:if test="count($importDocs) != 0">
                <xsl:call-template name="displayLog">
                    <xsl:with-param name="logContent">Les schémas suivants sont importés :</xsl:with-param>
                </xsl:call-template>
            </xsl:if>
            <xsl:for-each select="$importDocs">
                <xsl:call-template name="displayLog">
                    <xsl:with-param name="logContent">
                        <xsl:value-of select="./*[local-name()='schema']/@targetNamespace"/>
                    </xsl:with-param>
                </xsl:call-template>
            </xsl:for-each>
		
			<!--
				TEST DES VARIABLES
			-->
            <xsl:if test="count($targetNamespaceName) = 0">
                <xsl:call-template name="displayLogError">
                    <xsl:with-param name="logContent">Ce schéma n'a pas défini de targetNamespace</xsl:with-param>
                </xsl:call-template>
            </xsl:if>

			<!-- 
				RECUPERATION DES VARIABLES DU TEMPLATE OPEN OFFICE 
			-->
            <templates>
                <xsl:call-template name="computeTemplateVariables">
                    <xsl:with-param name="annotation" select="/*[local-name()='schema']/*[local-name()='annotation'][position()=1]"/>
                </xsl:call-template>
            </templates>

			<!-- 
				RECUPERATION DES EVOLUTIONS DU DICTIONNAIRE DES DONNES
			-->
            <evolutions>
                <xsl:variable name="evolutions" select="/*[local-name()='schema']/*[local-name()='annotation'][position()=1]/*[local-name()='documentation'][@source=$evolutionSchemeVarName]"/>
                <xsl:choose>
                    <xsl:when test="$evolutions">
                        <xsl:call-template name="displayEvolutions">
                            <xsl:with-param name="evolutions" select="$evolutions"/>
                        </xsl:call-template>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:call-template name="displayEvolutions">
                            <xsl:with-param name="evolutions" select="$undefinedLabel"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
            </evolutions>
			<!-- 
				TRAITEMENT DU DICTIONNAIRE DES ENTITES
			-->
            <entities>
                <xsl:for-each select="//*[local-name()='complexType']">
					<!--xsl:sort order="ascending" select="@name"/-->
                    <xsl:sort order="ascending" select="child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
                    <xsl:if test="key('entiteKey', @name)">
                        <xsl:call-template name="computeOneEntity">
                            <xsl:with-param name="complexType" select="."/>
                            <xsl:with-param name="importDocs" select="$importDocs"/>
                            <xsl:with-param name="currentPrefix" select="$currentPrefix"/>
                        </xsl:call-template>
                        <xsl:call-template name="insertHorizontalRule"/>
                    </xsl:if>
                </xsl:for-each>
                <xsl:variable name="extComplexTypes" select="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element'][not(key('entiteKey', substring-after(@type ,  ':' ))) and not(key('attributKey', substring-after(@type ,  ':' )))]"/>
				<!-- xsl:for-each select="//*[local-name()='complexType']/*[local-name()='sequence']/*[local-name()='element'][not(key('entiteKey', substring-after(@type ,  ':' ))) and not(key('attributKey', substring-after(@type ,  ':' )))]"-->
                <xsl:for-each select="$extComplexTypes">
                    <xsl:sort order="ascending" select="substring-after(@type ,  ':' )"/>
					<!--xsl:sort order="ascending" select="child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/-->
                    <xsl:variable name="pos">
                        <xsl:value-of select="position()"/>
                    </xsl:variable>
                    <xsl:variable name="crtName">
                        <xsl:value-of select="substring-after($extComplexTypes[position()=$pos]/@type ,  ':')"/>
                    </xsl:variable>
                    <xsl:variable name="nextPos">
                        <xsl:value-of select="$pos + 1"/>
                    </xsl:variable>
                    <xsl:variable name="nextName">
                        <xsl:value-of select="substring-after($extComplexTypes[position()=$nextPos]/@type ,  ':')"/>
                    </xsl:variable>
                    <xsl:if test="string($crtName) != string($nextName)">
                        <xsl:variable name="complexType" select="$importDocs//*[local-name()='complexType'][@name=$crtName and child::*[local-name()='sequence']]"/>
                        <xsl:if test="$complexType">
                            <xsl:variable name="targetNs" select="$importDocs//*[local-name()='complexType'][@name=$crtName and child::*[local-name()='sequence']]/../../*[local-name()='schema']/@targetNamespace"/>
                            <xsl:variable name="currentPrfx" select="local-name($importDocs//*[local-name()='complexType'][@name=$crtName and child::*[local-name()='sequence']]/../../*[local-name()='schema']/namespace::*[.=$targetNs])"/>
                            <xsl:call-template name="computeOneEntity">
                                <xsl:with-param name="complexType" select="$complexType"/>
                                <xsl:with-param name="importDocs" select="$importDocs"/>
                                <xsl:with-param name="mode">extern</xsl:with-param>
                                <xsl:with-param name="currentPrefix" select="$currentPrfx"/>
                            </xsl:call-template>
                            <xsl:call-template name="insertHorizontalRule"/>
                        </xsl:if>
                    </xsl:if>
                </xsl:for-each>
            </entities>

			<!-- 
				TRAITEMENT DU DICTIONNAIRE DES ATTRIBUTS
			-->
            <attributes>
                <xsl:for-each select="//*[local-name()='complexType']">
					<!--xsl:sort order="ascending" select="@name"/-->
                    <xsl:sort order="ascending" select="child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
                    <xsl:if test="key('attributKey', @name)">
                        <xsl:call-template name="computeOneAttribute">
                            <xsl:with-param name="complexType" select="."/>
                        </xsl:call-template>
                        <xsl:call-template name="insertHorizontalRule"/>
                    </xsl:if>
                </xsl:for-each>
            </attributes>

			<!--
				TRAITEMENT DES IMAGES DU SCHEMA CONCEPTUEL DES DONNEES
			-->
            <images>
                <xsl:call-template name="displayLog">
                    <xsl:with-param name="logContent">Traitement des images du schéma conceptuel des données</xsl:with-param>
                </xsl:call-template>
                <xsl:if test="$imagesNb &gt; 0">
                    <xsl:call-template name="displayOneImage">
                        <xsl:with-param name="index">1</xsl:with-param>
                    </xsl:call-template>
                </xsl:if>
            </images>
            <xsl:call-template name="displayLog">
                <xsl:with-param name="logContent">Fin de traitement du dictionnaire des données</xsl:with-param>
            </xsl:call-template>
        </root>
    </xsl:template>

		<!-- 
			TRAITEMENT D'UNE ENTITE
		-->
    <xsl:template name="computeOneEntity">
        <xsl:param name="complexType"/>
        <xsl:param name="importDocs"/>
        <xsl:param name="currentPrefix"/>
        <xsl:param name="mode"/>
        <xsl:call-template name="displayLog">
            <xsl:with-param name="logContent">Traitement de l'entité <xsl:value-of select="$complexType/@name"/>
            </xsl:with-param>
        </xsl:call-template>
		
			<!--
				TITRE DE CHAPITRE  D'UNE ENTITE
			-->
        <xsl:variable name="entityChapterName" select="$complexType/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
        <xsl:choose>
            <xsl:when test="count($entityChapterName) = 0 ">
                <xsl:call-template name="displayChapterTitleOfEntity">
                    <xsl:with-param name="text">
                        <xsl:value-of select="$undefinedLabel"/>
                    </xsl:with-param>
                    <xsl:with-param name="noteContent">    Le nom du chapitre de l'entité <xsl:value-of select="concat($currentPrefix, ':', $complexType/@name)"/> ne peut être résolu (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="displayChapterTitleOfEntity">
                    <xsl:with-param name="text" select="$entityChapterName"/>
                    <xsl:with-param name="ref" select="$complexType/@name"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:variable name="definitionContent" select="$complexType/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Definition']"/>
        <text:list text:style-name="WW8Num24">
			<!--
				CODE DE L'ENTITE
			-->
            <xsl:variable name="entityCode" select="$complexType/@id"/>
            <xsl:choose>
                <xsl:when test="count($entityCode) = 0 ">
                    <xsl:call-template name="displayLogWarning">
                        <xsl:with-param name="logContent">    Le code de l'entité <xsl:value-of select="concat($currentPrefix, ':', $complexType/@name)"/> ne peut être résolu (élément complexType/@id absent)</xsl:with-param>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="displayCodeOfEntity">
                        <xsl:with-param name="text" select="$entityCode"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>
						
			<!--
				NOM DE BALISE XML DE L'ENTITE
			-->
            <xsl:variable name="entityXmlMarkupName" select="$complexType/@name"/>
            <xsl:choose>
                <xsl:when test="count($entityXmlMarkupName) = 0 ">
                    <xsl:call-template name="displayXMLMarkNameOfEntity">
                        <xsl:with-param name="aliasNamespace"/>
                        <xsl:with-param name="elementName">
                            <xsl:value-of select="$undefinedLabel"/>
                        </xsl:with-param>
                        <xsl:with-param name="noteContent">    Le nom de la balise XML de l'entité ne peut être résolu (élément complexType/@name absent)</xsl:with-param>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="displayXMLMarkNameOfEntity">
                        <xsl:with-param name="aliasNamespace" select="$currentPrefix"/>
                        <xsl:with-param name="elementName" select="$complexType/@name"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>

			<!--
				DEFINITION DE L'ENTITE
			-->
            <xsl:variable name="textDefinition">
                <xsl:choose>
                    <xsl:when test="count($definitionContent) = 0">
                        <xsl:value-of select="$undefinedLabel"/>
                    </xsl:when>
                    <xsl:otherwise>
                        <xsl:choose>
                            <xsl:when test="contains($definitionContent, $nomenclatureStartStr) and contains($definitionContent, $nomenclatureEndStr)">
                                <xsl:value-of select="concat( substring-before ($definitionContent, $nomenclatureStartStr) , substring-after ($definitionContent, $nomenclatureEndStr))"/>
                            </xsl:when>
                            <xsl:otherwise>
                                <xsl:value-of select="$definitionContent"/>
                            </xsl:otherwise>
                        </xsl:choose>
                    </xsl:otherwise>
                </xsl:choose>
            </xsl:variable>
            <xsl:variable name="noteContentDefinition">
                <xsl:choose>
                    <xsl:when test="count($definitionContent) = 0">
                        <xsl:value-of select="'   La définition de l entité '"/>
                        <xsl:value-of select="concat($currentPrefix, ':', $complexType/@name)"/>
                        <xsl:value-of select="' ne peut être résolue (élément complexType/annotation/definition/@source=Definition absent)'"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="displayDefinition">
                <xsl:with-param name="noteContent" select="$noteContentDefinition"/>
            </xsl:call-template>
        </text:list>
        <xsl:variable name="textDefinition">
            <xsl:choose>
                <xsl:when test="count($definitionContent) = 0">
                    <xsl:value-of select="$undefinedLabel"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="contains($definitionContent, $nomenclatureStartStr) and contains($definitionContent, $nomenclatureEndStr)">
                            <xsl:value-of select="concat( substring-before ($definitionContent, $nomenclatureStartStr) , substring-after ($definitionContent, $nomenclatureEndStr))"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$definitionContent"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="formatDefinition">
            <xsl:with-param name="text" select="$textDefinition"/>
        </xsl:call-template>
        <xsl:choose>
            <xsl:when test="child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [ ( key( 'infoKey11' , substring-after(@type ,  ':' ) ) or key ( 'infoKey01' , substring-after(@type , ':' ) ) ) and (  key ( 'attributKey' , substring-after(@type , ':' ) ) or substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='simpleContent']/../@name ) ]">
                <xsl:call-template name="displayInfoOfEntityTitle"/>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="displayLogWarning">
                    <xsl:with-param name="logContent">    Cette entité n'a pas d'informations</xsl:with-param>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
        <xsl:if test="string($mode) != string('extern')">
			<!--
				LISTE DES ATTRIBUTS (1,1)
			-->
            <text:list text:style-name="WW8Num20">
                <xsl:for-each select="child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [  key( 'infoKey11' , substring-after(@type ,  ':' ) )  and (  key ( 'attributKey' , substring-after(@type , ':' ) ) or substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='simpleContent']/../@name ) ]">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="attributType" select="substring-after($type, ':')"/>
                    <xsl:variable name="attributLabel" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('attributKey', $attributType)">
                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($attribut) = 0 ">
                                    <xsl:call-template name="displayAttribute11OfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$attributLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (1,1) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute11OfEntity">
									<!--xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/-->
                                        <xsl:with-param name="text" select="$attribut"/>
                                        <xsl:with-param name="attributName" select="$attribut"/>
                                        <xsl:with-param name="ref" select="$attributType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:choose>
                                <xsl:when test="$importDocs//*[local-name()='complexType'][@name=$attributType]/*[local-name()='simpleContent']/../*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']">
                                    <xsl:for-each select="$importDocs">
                                        <xsl:if test="key('attributKey', $attributType)">
                                            <xsl:variable name="currentTargetNamespace" select=".//*[local-name()='schema']/@targetNamespace"/>
                                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                                            <xsl:variable name="uri">
                                                <xsl:for-each select="xalan:nodeset($importDocsTmp)/url">
                                                    <xsl:if test="starts-with(., $currentTargetNamespace)">
                                                        <xsl:value-of select="concat(., '#', $attributType)"/>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </xsl:variable>
                                            <xsl:call-template name="displayAttribute11OfEntity">
                                                <xsl:with-param name="text" select="$attribut"/>
											<!--xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/-->
                                                <xsl:with-param name="mode">extern</xsl:with-param>
                                                <xsl:with-param name="relativeUrl" select="concat(substring-before($uri, '.xsd'), '.html', substring-after($uri, '.xsd'))"/>
                                            </xsl:call-template>
                                        </xsl:if>
                                    </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute11OfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$attributLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (1,1) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
			
			<!--
				LISTE DES ATTRIBUTS (0,1)
			-->
                <xsl:for-each select="child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [  key( 'infoKey01' , substring-after(@type ,  ':' ) )  and (  key ( 'attributKey' , substring-after(@type , ':' ) ) or substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='simpleContent']/../@name ) ]">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="attributType" select="substring-after($type, ':')"/>
                    <xsl:variable name="attributLabel" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('attributKey', $attributType)">
                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($attribut) = 0 ">
                                    <xsl:call-template name="displayAttribute01OfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (0,1) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute01OfEntity">	
									<!--xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/-->
                                        <xsl:with-param name="text" select="$attribut"/>
                                        <xsl:with-param name="attributName" select="$attribut"/>
                                        <xsl:with-param name="ref" select="$attributType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:choose>
                                <xsl:when test="$importDocs//*[local-name()='complexType'][@name=$attributType]/*[local-name()='simpleContent']/../*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']">
                                    <xsl:for-each select="$importDocs">
                                        <xsl:if test="key('attributKey', $attributType)">
                                            <xsl:variable name="currentTargetNamespace" select=".//*[local-name()='schema']/@targetNamespace"/>
                                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                                            <xsl:variable name="uri">
                                                <xsl:for-each select="xalan:nodeset($importDocsTmp)/url">
                                                    <xsl:if test="starts-with(., $currentTargetNamespace)">
                                                        <xsl:value-of select="concat(., '#', $attributType)"/>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </xsl:variable>
                                            <xsl:call-template name="displayAttribute01OfEntity">
                                                <xsl:with-param name="text" select="$attribut"/>
											<!--xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/-->
                                                <xsl:with-param name="mode">extern</xsl:with-param>
                                                <xsl:with-param name="relativeUrl" select="concat(substring-before($uri, '.xsd'), '.html', substring-after($uri, '.xsd'))"/>
                                            </xsl:call-template>
                                        </xsl:if>
                                    </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute01OfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (0,1) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </text:list>
            <xsl:if test="child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [ ( key( 'infoKey0n' , substring-after(@type ,  ':' )  ) and ( key( 'attributKey' , substring-after(@type ,  ':' )  )  or   substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='simpleContent']/../@name )  )  or  (  key( 'entiteKey' , substring-after(@type ,  ':' ) )  or ( not ( key( 'attributKey' , substring-after(@type ,  ':' )  )  )  and  substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='sequence']/../@name )  ) ]">
                <xsl:call-template name="displayAssoOfEntityTitle"/>
            </xsl:if>

				<!--
					LISTE DES ATTRIBUTS (0,n)
				-->
            <text:list text:style-name="WW8Num20">
                <xsl:for-each select="$complexType/child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [  key( 'infoKey0n' , substring-after(@type ,  ':' ) )  and (  key ( 'attributKey' , substring-after(@type , ':' ) ) or substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='simpleContent']/../@name ) ]">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="attributType" select="substring-after($type, ':')"/>
                    <xsl:variable name="attributLabel" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('attributKey', $attributType)">
                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($attribut) = 0 ">
                                    <xsl:call-template name="displayAttribute0nOfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (0,n) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute0nOfEntity">
									<!--xsl:with-param name="text" select="$attributLabel"/-->
                                        <xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/>
                                        <xsl:with-param name="attributName" select="$attribut"/>
                                        <xsl:with-param name="ref" select="$attributType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:choose>
                                <xsl:when test="$importDocs//*[local-name()='complexType'][@name=$attributType]/*[local-name()='simpleContent']/../*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']">
                                    <xsl:for-each select="$importDocs">
                                        <xsl:if test="key('attributKey', $attributType)">
                                            <xsl:variable name="currentTargetNamespace" select=".//*[local-name()='schema']/@targetNamespace"/>
                                            <xsl:variable name="attribut" select="key('attributKey', $attributType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                                            <xsl:variable name="uri">
                                                <xsl:for-each select="xalan:nodeset($importDocsTmp)/url">
                                                    <xsl:if test="starts-with(., $currentTargetNamespace)">
                                                        <xsl:value-of select="concat(., '#', $attributType)"/>
                                                    </xsl:if>
                                                </xsl:for-each>
                                            </xsl:variable>
                                            <xsl:call-template name="displayAttribute0nOfEntity">
											<!--xsl:with-param name="text" select="$attributLabel"/-->
                                                <xsl:with-param name="text" select="concat($attribut, ' / ', $attributLabel)"/>
                                                <xsl:with-param name="mode">extern</xsl:with-param>
                                                <xsl:with-param name="relativeUrl" select="concat(substring-before($uri, '.xsd'), '.html', substring-after($uri, '.xsd'))"/>
                                            </xsl:call-template>
                                        </xsl:if>
                                    </xsl:for-each>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayAttribute0nOfEntity">
                                        <xsl:with-param name="text">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'attribut <xsl:value-of select="$type"/> de cardinalité (0,n) n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>

				<!--
					LISTE DES ENTITES
				-->
                <xsl:for-each select="$complexType/child::*[ local-name() = 'sequence' ] / child::*[ local-name() = 'element' ] [ key( 'entiteKey' , substring-after(@type ,  ':' ) )  or ( not ( key( 'attributKey' , substring-after(@type ,  ':' )  )  )  and  substring-after(@type,':')=$importDocs//*[local-name()='complexType']/*[local-name()='sequence']/../@name )  ]">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="entityType" select="substring-after($type, ':')"/>
                    <xsl:variable name="entityLabel" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('entiteKey', $entityType) ">
                            <xsl:variable name="entity" select="key('entiteKey', $entityType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($entity) = 0 ">
                                    <xsl:call-template name="displayEntityInfoOfEntity">
                                        <xsl:with-param name="entityName">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="minOccurs" select="@minOccurs"/>
                                        <xsl:with-param name="maxOccurs" select="@maxOccurs"/>
                                        <xsl:with-param name="noteContent">    L'entité <xsl:value-of select="$type"/> n'a pas de libellé associé (élément complexType/sequence/element/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayEntityInfoOfEntity">
									<!--xsl:with-param name="entityLabel" select="$entityLabel"/-->
                                        <xsl:with-param name="entityLabel" select="concat( $entity, ' / ', $entityLabel)"/>
                                        <xsl:with-param name="entityName" select="$entity"/>
                                        <xsl:with-param name="minOccurs" select="@minOccurs"/>
                                        <xsl:with-param name="maxOccurs" select="@maxOccurs"/>
                                        <xsl:with-param name="ref" select="$entityType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:if test="not(key('attributKey',$entityType))">
                                <xsl:choose>
                                    <xsl:when test="$importDocs//*[local-name()='complexType'][@name=$entityType]/*[local-name()='sequence']/../*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']">
                                        <xsl:for-each select="$importDocs">
                                            <xsl:if test="key('entiteKey', $entityType)">
                                                <xsl:variable name="currentTargetNamespace" select=".//*[local-name()='schema']/@targetNamespace"/>
                                                <xsl:variable name="entity" select="key('entiteKey', $entityType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                                                <xsl:variable name="uri">
                                                    <xsl:for-each select="xalan:nodeset($importDocsTmp)/url">
                                                        <xsl:if test="starts-with(., $currentTargetNamespace)">
                                                            <xsl:value-of select="concat(., '#', $entityType)"/>
                                                        </xsl:if>
                                                    </xsl:for-each>
                                                </xsl:variable>
                                                <xsl:call-template name="displayEntityInfoOfEntity">
                                                    <xsl:with-param name="entityLabel" select="concat( $entity, ' / ', $entityLabel)"/>
                                                    <xsl:with-param name="entityName" select="$entityLabel"/>
                                                    <xsl:with-param name="minOccurs" select="@minOccurs"/>
                                                    <xsl:with-param name="maxOccurs" select="@maxOccurs"/>
												<!--xsl:with-param name="mode">extern</xsl:with-param-->
                                                    <xsl:with-param name="ref" select="$entityType"/>
                                                    <xsl:with-param name="relativeUrl" select="concat(substring-before($uri, '.xsd'), '.html', substring-after($uri, '.xsd'))"/>
                                                </xsl:call-template>
                                            </xsl:if>
                                        </xsl:for-each>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <xsl:call-template name="displayEntityInfoOfEntity">
                                            <xsl:with-param name="entityName">
                                                <xsl:value-of select="$undefinedLabel"/>
                                            </xsl:with-param>
                                            <xsl:with-param name="minOccurs" select="@minOccurs"/>
                                            <xsl:with-param name="maxOccurs" select="@maxOccurs"/>
                                            <xsl:with-param name="noteContent">    L'entité <xsl:value-of select="$type"/> n'a pas de libellé associé (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                        </xsl:call-template>
                                    </xsl:otherwise>
                                </xsl:choose>
                            </xsl:if>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:for-each>
            </text:list>
            <xsl:if test="child::*[ local-name() = 'sequence' ] / child::* [ local-name() = 'choice' ] / child::*[ local-name() = 'element' ]">
                <xsl:call-template name="displayEntityChildTitle"/>
            </xsl:if>

				<!--
					LISTE DES ENTITES FILLES
				-->
            <text:list text:style-name="WW8Num20">
                <xsl:for-each select="$complexType/child::*[ local-name() = 'sequence' ]  / child::* [ local-name() = 'choice' ] / child::*[ local-name() = 'element' ] ">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="entityType" select="substring-after($type, ':')"/>
                    <xsl:variable name="entityLabel" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('entiteKey', $entityType) ">
                            <xsl:variable name="entity" select="key('entiteKey', $entityType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($entity) = 0 ">
                                    <xsl:call-template name="displayEntityChildInfoOfEntity">
                                        <xsl:with-param name="entityName">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'entité <xsl:value-of select="$type"/> n'a pas de libellé associé (élément complexType/sequence/element/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayEntityChildInfoOfEntity">
                                        <xsl:with-param name="entityLabel" select="$entity"/>
                                        <xsl:with-param name="entityName" select="$entity"/>
                                        <xsl:with-param name="ref" select="$entityType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </text:list>
            <xsl:variable name="elementName" select="@name"/>
            <xsl:if test="//child::*[ local-name() = 'complexType'] / child::*[ local-name() = 'sequence' ] / child::* [ local-name() = 'choice' ] / child::*[ local-name() = 'element' ] [@name = $elementName]">
                <xsl:call-template name="displayEntityParentTitle"/>
            </xsl:if>

			<!--
				LISTE DES ENTITES PARENTES
			-->
            <text:list text:style-name="WW8Num20">
                <xsl:for-each select="//child::*[ local-name() = 'complexType'] / child::*[ local-name() = 'sequence' ] / child::* [ local-name() = 'choice' ] / child::*[ local-name() = 'element' ] [@name = $elementName] ">
                    <xsl:sort order="ascending" select="child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:variable name="type" select="@type"/>
                    <xsl:variable name="entityType" select="substring-after($type, ':')"/>
                    <xsl:variable name="entityLabel" select="../../../child::*[ local-name() = 'annotation' ]/child::*[ local-name() = 'documentation' ][ @source = 'Libelle' ]"/>
                    <xsl:choose>
                        <xsl:when test="key('entiteKey', $entityType) ">
                            <xsl:variable name="entity" select="key('entiteKey', $entityType)/*[local-name()='annotation']/*[local-name()='documentation'][@source='Libelle']"/>
                            <xsl:choose>
                                <xsl:when test="count($entity) = 0 ">
                                    <xsl:call-template name="displayEntityChildInfoOfEntity">
                                        <xsl:with-param name="entityName">
                                            <xsl:value-of select="$undefinedLabel"/>
                                        </xsl:with-param>
                                        <xsl:with-param name="noteContent">    L'entité <xsl:value-of select="$type"/> n'a pas de libellé associé (élément complexType/sequence/element/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                                    </xsl:call-template>
                                </xsl:when>
                                <xsl:otherwise>
                                    <xsl:call-template name="displayEntityChildInfoOfEntity">
                                        <xsl:with-param name="entityLabel" select="$entity"/>
                                        <xsl:with-param name="entityName" select="$entity"/>
                                        <xsl:with-param name="ref" select="$entityType"/>
                                    </xsl:call-template>
                                </xsl:otherwise>
                            </xsl:choose>
                        </xsl:when>
                    </xsl:choose>
                </xsl:for-each>
            </text:list>
        </xsl:if>
    </xsl:template>
		
		<!-- 
			TRAITEMENT D'UN ATTRIBUT
		-->
    <xsl:template name="computeOneAttribute">
        <xsl:param name="complexType"/>
        <xsl:variable name="definitionContent" select="$complexType/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Definition']"/>
        <xsl:call-template name="displayLog">
            <xsl:with-param name="logContent">Traitement de l'attribut <xsl:value-of select="$complexType/@name"/>
            </xsl:with-param>
        </xsl:call-template>								

			<!--
				TITRE DE CHAPITRE D'UN ATTRIBUT
			-->
        <xsl:variable name="attributeChapterName" select="$complexType/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
        <xsl:choose>
            <xsl:when test="count($attributeChapterName) = 0 ">
                <xsl:call-template name="displayChapterTitleOfAttribute">
                    <xsl:with-param name="text">
                        <xsl:value-of select="$undefinedLabel"/>
                    </xsl:with-param>
                    <xsl:with-param name="noteContent">    Le nom du chapitre de l'attribut <xsl:value-of select="concat($currentPrefix, ':', @name)"/> ne peut être résolu (élément complexType/annotation/documentation/@source=Libelle absent)</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:otherwise>
                <xsl:call-template name="displayChapterTitleOfAttribute">
                    <xsl:with-param name="text" select="$attributeChapterName"/>
                    <xsl:with-param name="ref" select="@name"/>
                </xsl:call-template>
            </xsl:otherwise>
        </xsl:choose>
			
			<!--
				NOM DE BALISE XML DE L'ATTRIBUT
			-->
        <text:list text:style-name="WW8Num24">
            <xsl:variable name="attributeXmlMarkupName" select="$complexType/@name"/>
            <xsl:choose>
                <xsl:when test="count($attributeXmlMarkupName) = 0 ">
                    <xsl:call-template name="displayXMLMarkNameOfAttribute">
                        <xsl:with-param name="aliasNamespace"/>
                        <xsl:with-param name="elementName">
                            <xsl:value-of select="$undefinedLabel"/>
                        </xsl:with-param>
                        <xsl:with-param name="noteContent">    Le nom de la balise XML de l'attribut ne peut être résolu (élément complexType/@name absent)</xsl:with-param>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="displayXMLMarkNameOfAttribute">
                        <xsl:with-param name="aliasNamespace" select="$currentPrefix"/>
                        <xsl:with-param name="elementName" select="$complexType/@name"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>

			<!--
				CODE DE L'ATTRIBUT
			-->
            <xsl:variable name="attributeCode" select="$complexType/@id"/>
            <xsl:choose>
                <xsl:when test="count($attributeCode) = 0 ">
                    <xsl:call-template name="displayLogWarning">
                        <xsl:with-param name="logContent">    Le code de l'attribut <xsl:value-of select="concat($currentPrefix, ':', @name)"/> ne peut être résolu (élément complexType/@id absent)</xsl:with-param>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:call-template name="displayCodeOfAttribute">
                        <xsl:with-param name="text" select="$complexType/@id"/>
                    </xsl:call-template>
                </xsl:otherwise>
            </xsl:choose>

			<!--
				NOM DE L'OBJET/LIEN XML DE L'ATTRIBUT
			-->
            <xsl:variable name="attributeLinkObjectName" select="key('infoKey', @name)/parent::*/parent::*/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
            <xsl:choose>
                <xsl:when test="count($attributeLinkObjectName) = 0">
                    <xsl:call-template name="displayLinkObjectNameOfAttribute">
                        <xsl:with-param name="objects">
                            <xsl:value-of select="$undefinedLabel"/>
                        </xsl:with-param>
                        <xsl:with-param name="noteContent">    Aucun Objet/Lien n'est défini pour l'attribut <xsl:value-of select="concat('$currentPrefix', ':', $complexType/@name)"/>
                        </xsl:with-param>
                    </xsl:call-template>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="count($attributeLinkObjectName) != count(key('infoKey', $complexType/@name))">
                            <xsl:call-template name="displayLinkObjectNameOfAttribute">
                                <xsl:with-param name="objects">
                                    <xsl:value-of select="$undefinedLabel"/>
                                </xsl:with-param>
                                <xsl:with-param name="noteContent">    Certains Objet/Lien n'ont pu être résolus pour l'attribut <xsl:value-of select="concat('$currentPrefix', ':', $complexType/@name)"/> (élément(s) complexType/annotation/documentation/@source=Libelle absent(s))</xsl:with-param>
                            </xsl:call-template>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:call-template name="displayLinkObjectNameOfAttribute">
                                <xsl:with-param name="objects" select="$attributeLinkObjectName"/>
                            </xsl:call-template>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>

			<!--
				CARACTERISTIQUES DE L'ATTRIBUT
			-->
            <xsl:call-template name="computeCaracteristicsOfAttribute">
                <xsl:with-param name="complexType" select="."/>
            </xsl:call-template>

			<!--
				DEFINITION DE L'ATTRIBUT
			-->
            <xsl:variable name="noteContentDefinition">
                <xsl:choose>
                    <xsl:when test="count($definitionContent) = 0">
                        <xsl:value-of select="'La définition de l attribut '"/>
                        <xsl:value-of select="concat($currentPrefix, ':', @name)"/>
                        <xsl:value-of select="' ne peut être résolue (élément complexType/annotation/definition/@source=Definition absent)'"/>
                    </xsl:when>
                </xsl:choose>
            </xsl:variable>
            <xsl:call-template name="displayDefinition">
                <xsl:with-param name="noteContent" select="$noteContentDefinition"/>
            </xsl:call-template>
        </text:list>
        <xsl:variable name="textDefinition">
            <xsl:choose>
                <xsl:when test="count($definitionContent) = 0 ">
                    <xsl:value-of select="$undefinedLabel"/>
                </xsl:when>
                <xsl:otherwise>
                    <xsl:choose>
                        <xsl:when test="contains($definitionContent, $nomenclatureStartStr) and contains($definitionContent, $nomenclatureEndStr)">
                            <xsl:value-of select="concat( substring-before ($definitionContent, $nomenclatureStartStr) , substring-after ($definitionContent, $nomenclatureEndStr))"/>
                        </xsl:when>
                        <xsl:otherwise>
                            <xsl:value-of select="$definitionContent"/>
                        </xsl:otherwise>
                    </xsl:choose>
                </xsl:otherwise>
            </xsl:choose>
        </xsl:variable>
        <xsl:call-template name="formatDefinition">
            <xsl:with-param name="text" select="$textDefinition"/>
        </xsl:call-template>
        <xsl:call-template name="computeDefinitionOfAttribute">
            <xsl:with-param name="complexType" select="."/>
        </xsl:call-template>
    </xsl:template>
    <xsl:template name="computeDefinitionOfAttribute">
        <xsl:param name="complexType"/>
        <xsl:variable name="type" select="substring-after($complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/@base, ':')"/>
			<!-- Attribut de type CodeType -->
        <xsl:if test="$type = 'CodeType' and $complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='enumeration']">
            <xsl:variable name="codeData" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='enumeration']/@value"/>
            <xsl:variable name="mnemoData" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='enumeration']/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Mnemonique']"/>
            <xsl:variable name="labelData" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='enumeration']/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Libelle']"/>
            <xsl:variable name="definitionData" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='enumeration']/child::*[local-name()='annotation']/child::*[local-name()='documentation'][@source='Definition']"/>
            <xsl:if test="count($codeData) != count($mnemoData) or count($labelData) != count($mnemoData) or count($labelData) != count($codeData)">
                <xsl:call-template name="displayLogError">
                    <xsl:with-param name="logContent">Le contenu de certaines cellules du tableau CodeType ne peut être résolu</xsl:with-param>
                </xsl:call-template>
            </xsl:if>
				<!-- Tableau -->
            <xsl:call-template name="displayCodeTypeTable">
                <xsl:with-param name="header1">
                    <xsl:value-of select="$codeHeader"/>
                </xsl:with-param>
                <xsl:with-param name="header2">
                    <xsl:value-of select="$mnemoHeader"/>
                </xsl:with-param>
                <xsl:with-param name="header3">
                    <xsl:value-of select="$labelHeader"/>
                </xsl:with-param>
                <xsl:with-param name="header4">
                    <xsl:value-of select="$definitionHeader"/>
                </xsl:with-param>
                <xsl:with-param name="col1" select="$codeData"/>
                <xsl:with-param name="col2" select="$mnemoData"/>
                <xsl:with-param name="col3" select="$labelData"/>
                <xsl:with-param name="col4" select="$definitionData"/>
                <xsl:with-param name="listID" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/child::*[local-name()='attribute'][@name='listID']/@fixed"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
    <xsl:template name="computeCaracteristicsOfAttribute">
        <xsl:param name="complexType"/>
        <xsl:variable name="type" select="substring-after(child::*[local-name()='simpleContent']/child::*[local-name()='restriction']/@base, ':')"/>
        <xsl:variable name="restriction" select="$complexType/child::*[local-name()='simpleContent']/child::*[local-name()='restriction']"/>
        <xsl:choose>
            <xsl:when test=" $type = 'TextType' ">
                <xsl:call-template name="displayTexteOrCharacterFormat">
                    <xsl:with-param name="isLengthDefined" select="$restriction/child::*[local-name()='length'] | $restriction/child::*[local-name()='minLength'] | $restriction/child::*[local-name()='maxLength']"/>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='length']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Longueur impérative</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='minLength']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Longueur minimale</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='maxLength']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Longueur maximale</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='pattern']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Expression régulière</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayMultiValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='enumeration']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur(s)</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$type='NumericType'">
                <xsl:call-template name="displayNumericFormat"/>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='maxInclusive']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur maximum inclusive</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='minInclusive']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur minimum inclusive</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='maxExclusive']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur maximum exclusive</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='minExclusive']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur minimum exclusive</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='totalDigits']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Nombre total de chiffres</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='fractionlDigits']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Nombre total de chiffres après la virgule</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='pattern']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Pattern</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayMultiValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='enumeration']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur(s)</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$type='DateType'">
                <xsl:call-template name="displayDateFormat"/>
            </xsl:when>
            <xsl:when test="$type='TimeType'">
                <xsl:call-template name="displayTimeFormat"/>
            </xsl:when>
            <xsl:when test="$type='DateTimeType'">
                <xsl:call-template name="displayDateTimeFormat"/>
            </xsl:when>
            <xsl:when test="$type='IndicatorType'">
                <xsl:call-template name="displayIndicatorFormat"/>
            </xsl:when>
            <xsl:when test="$type='BinaryObjectType'">
                <xsl:call-template name="displayBinaryFormat"/>
            </xsl:when>
            <xsl:when test="$type='IdentifierType'">
                <xsl:call-template name="displayTexteOrCharacterFormat">
                    <xsl:with-param name="isLengthDefined" select="$restriction/child::*[local-name()='maxLength']"/>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='maxLength']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Longueur</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='pattern']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Pattern</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayMultiValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='enumeration']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Valeur(s)</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue">Clef primaire</xsl:with-param>
                    <xsl:with-param name="caracteristicLabel">Nature de l'attribut</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
            <xsl:when test="$type='CodeType'">
                <xsl:call-template name="displayTexteOrCharacterFormat">
                    <xsl:with-param name="isLengthDefined" select="$restriction/child::*[local-name()='maxLength']"/>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='maxLength']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Longueur</xsl:with-param>
                </xsl:call-template>
                <xsl:call-template name="displayOneSingleValueCaracteristicOfAttribute">
                    <xsl:with-param name="caracteristicValue" select="$restriction/child::*[local-name()='pattern']/@value"/>
                    <xsl:with-param name="caracteristicLabel">Pattern</xsl:with-param>
                </xsl:call-template>
            </xsl:when>
        </xsl:choose>
    </xsl:template>
    <xsl:template name="displayOneImage">
        <xsl:param name="index"/>
        <xsl:variable name="name" select="concat('Image', $index)"/>
        <xsl:call-template name="displayImage">
            <xsl:with-param name="imageFileName" select="$name"/>
            <xsl:with-param name="imageName" select="$name"/>
            <xsl:with-param name="prefixURL" select="$imagePrefixURL"/>
        </xsl:call-template>
        <xsl:if test="$index &lt; $imagesNb">
            <xsl:call-template name="displayOneImage">
                <xsl:with-param name="index" select="$index + 1"/>
            </xsl:call-template>
        </xsl:if>
    </xsl:template>
</xsl:stylesheet>