Chapitre I - Transformation XML - RTF
        Structure du document source XML
                Description de la DTD utilisée
        Transformation XSLT
                Prologue
                Règles pour la transcription RTF d'un style
                Règles pour rendre inoffensifs certains caractères en RTF
                Entrées d'index
                Feuille de style complète


Chapitre I - Transformation XML - RTF

Structure du document source XML

<!--
**************************************************************************
-->
<titre2 id="include.titre.10.Decoupe" indexWords="1,2">Instruction xsl:import</titre2>


<!--
**************************************************************************
-->
<titre3 id="importSyntaxe.titre.11.Decoupe">Syntaxe</titre3>


<titreCode>xsl:import</titreCode>
<listingAvecTitre><![CDATA[<xsl:import
    href="..."
/>]]></listingAvecTitre>



<paragraphe>L'attribut href <tresImportant> ne doit pas </tresImportant> être un descripteur de valeur différée.
</paragraphe>

<paragraphe>L'instruction <codeDansTexte avant=" " après=" ">xsl:import</codeDansTexte> doit apparaître comme instruction de premier niveau, et de plus doit apparaître avant toute autre instruction.
</paragraphe>


<!--
**************************************************************************
-->
<titre3 id="importSemantique.titre.12.Decoupe"> Sémantique</titre3>

<paragraphe>L'instruction <codeDansTexte avant=" " après=" ">xsl:import</codeDansTexte> permet d'incorporer au fichier source XSLT courant les instructions XSLT d'un autre fichier source XSLT dont l'URI est fourni par l'attribut <codeDansTexte avant=" " >href</codeDansTexte>. La différence avec <codeDansTexte avant=" " après=" ">xsl:include</codeDansTexte> tient à ce que les conflits, en cas de définitions multiples d'une même instruction XSLT, ne sont pas nécessairement des cas d'erreurs, et peuvent être résolus grâce à des règles spécifiques. 
</paragraphe>


<!--
**************************************************************************
-->
<titre4 id="importSemantiqueproc.titre.13.Decoupe"> Processus mis en œuvre</titre4>

<index indexWords="1,4,5">Instanciation de l'instruction xsl:import</index>

<index indexWords="1,3,7,8">Détection de conflits dus à l'instruction xsl:import</index>
<index indexWords="1,4,9">Calcul de la préséance des feuilles importées par xsl:import</index>

<paragraphe>Le processus d'incorporation des instructions XSLT provenant d'une feuille de style importée est le même que dans le cas d'une inclusion (voir <renvoiVersTitre idRef="includeSemantiqueproc.titre.5.Decoupe" avant=" " />). Ce qui change, c'est l'interprétation du résultat une fois l'incorporation terminée. On peut exprimer cela assez facilement sur un dessin (voir <renvoiVersFigure idRef="include-import.fig.1.Decoupe" avant=" " />, où <italiques> A</italiques>, <italiques> B</italiques>, <italiques> C</italiques>, et <italiques> D </italiques> représentent des instructions XSLT quelconques) : dans le cas d'une inclusion, la double présence de l'instruction <italiques> B </italiques> pose (en général) problème; mais dans le cas d'une importation, elle ne pose pas problème.
</paragraphe>


<figure id="include-import.fig.1.Decoupe" dir="images/InstructionsDecoupage" file="include-import.eps" legende='Comparaison inclusion-importation'/>


<remarque  titre="Note">La <renvoiVersFigure idRef="include-import.fig.1.Decoupe" avant=" " après=" " /> suggère un conflit potentiel entre l'élément <italiques> B </italiques> de la feuille principale et l'élément <italiques> B </italiques> de la feuille importée. Néanmoins, il faut garder à l'esprit qu'une stricte identité d'élément n'est pas nécessaire à l'apparition d'un conflit : deux règles de transformation de motifs différents peuvent très bien engendrer un conflit sur un certain nœud, si les deux motifs concordent simultanément avec ce nœud. La figure est ici un support visuel qui permet de mettre en évidence les endroits où l'on discute d'un conflit, mais elle ne doit pas faire croire que les conflits ne peuvent pas surgir ailleurs.
</remarque>

Description de la DTD utilisée

xml-rtf.dtd
<?xml version='1.0' encoding='UTF-16' ?>

<!-- [
        DTD pour la traduction RTF de documents XML
        Chaque <!ELEMENT ... > correspond à un style de feuille de style RTF.
-->

    
<!--  ==================================================================== -->
<!--  Entités définissant des raccourcis d'écriture dans 
      les définitions d'éléments ou d'attributs -->
<!--  ==================================================================== -->
    
    
    
    <!ENTITY % fragmentDeTexte "#PCDATA | subtil | italiques | titreOeuvre | 
                                tresImportant | codeDansTexte | 
                                codeRTFDansTexte |
                                renvoiVersTableau | renvoiVersFigure | 
                                renvoiVersTitre   | espace |  
                                br | refBiblio        
                                " >
                                
    <!ENTITY % fragmentDeTexteAvecNoteBP "#PCDATA | subtil | italiques | 
                                          titreOeuvre | tresImportant | 
                                          codeDansTexte | codeRTFDansTexte |
                                          renvoiVersTableau | 
                                          renvoiVersFigure | 
                                          renvoiVersTitre   | espace |
                                          br | noteBP | refBiblio                  
                                " >
                                
    <!ENTITY % elementDeListing "#PCDATA | pseudoCode | codeFaux                  
                                " >

    <!-- définition des éléments associés -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        
        <!ELEMENT subtil (#PCDATA) >
        <!ELEMENT italiques (#PCDATA) >
        
        <!ELEMENT titreOeuvre (#PCDATA) >
        
        <!ELEMENT tresImportant (#PCDATA) >
        
        <!ELEMENT codeDansTexte (#PCDATA)>
        <!ATTLIST codeDansTexte avant CDATA #IMPLIED >
        <!ATTLIST codeDansTexte après CDATA #IMPLIED >
        
        <!ELEMENT codeRTFDansTexte (#PCDATA)>
        <!ATTLIST codeRTFDansTexte avant CDATA #IMPLIED >
        <!ATTLIST codeRTFDansTexte après CDATA #IMPLIED >
        
        <!ELEMENT pseudoCode (#PCDATA)>
        
        <!ELEMENT codeFaux (#PCDATA)>
        
        <!ELEMENT renvoiVersFigure (#PCDATA)>
        <!ATTLIST renvoiVersFigure idRef IDREF #REQUIRED >
        <!ATTLIST renvoiVersFigure avant CDATA #IMPLIED >
        <!ATTLIST renvoiVersFigure après CDATA #IMPLIED >
        <!ATTLIST renvoiVersTitre postIt CDATA #IMPLIED >
        
        <!ELEMENT renvoiVersTitre (#PCDATA)>
        <!ATTLIST renvoiVersTitre idRef IDREF #REQUIRED >
        <!ATTLIST renvoiVersTitre avant CDATA #IMPLIED >
        <!ATTLIST renvoiVersTitre après CDATA #IMPLIED >
        <!ATTLIST renvoiVersTitre postIt CDATA #IMPLIED >
        
        <!ELEMENT renvoiVersTableau (#PCDATA)>
        <!ATTLIST renvoiVersTableau idRef IDREF #REQUIRED >
        <!ATTLIST renvoiVersTableau avant CDATA #IMPLIED >
        <!ATTLIST renvoiVersTableau après CDATA #IMPLIED >
        <!ATTLIST renvoiVersTitre postIt CDATA #IMPLIED >
        
        
        <!ELEMENT refBiblio (#PCDATA)>
        <!ATTLIST refBiblio idRef IDREF #REQUIRED >
        
        <!ELEMENT index (#PCDATA)>
        <!ATTLIST index indexWords  CDATA #IMPLIED >
        
        <!ELEMENT espace EMPTY >
        
        <!ELEMENT br EMPTY >
        
        <!ELEMENT aerationVerticale EMPTY >
        
        
    
    <!ENTITY % blocDeTexte "partie | titreChapitre | titreAnnexe |
                            titre2 | titre3 | titre4 | titre5 |
                            paragraphe | tableau | remarque | 
                            figure | listing | listingRTF | 
                            listingPseudoCode |
                            codeUneLigne | aerationVerticale |
                            fichier | liste | listeANumero | 
                            ligneCodeAvecCommentaire | 
                            commentaireLigneDeCode | index |
                            titreCode | listingAvecTitre | 
                            sousTitreCommentaire |
                            exemplePourSousTitreDeCommentaire
                           " > 
                               
    <!ENTITY % titre.attributs "id       ID    #REQUIRED
                                numero   CDATA #IMPLIED
                                indexWords CDATA #IMPLIED   
                               ">                   

    <!-- définition des éléments associés -->
    <!-- ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -->
        
        <!ELEMENT partie (%fragmentDeTexte;)* >
        <!ATTLIST partie %titre.attributs; >
        
        <!ELEMENT titreChapitre (%fragmentDeTexte;)* >
        <!ATTLIST titreChapitre %titre.attributs; >
        
        <!ELEMENT titreAnnexe (%fragmentDeTexte;)* >
        <!ATTLIST titreAnnexe %titre.attributs; >
        
        <!ELEMENT titre2 (%fragmentDeTexteAvecNoteBP;)* >
        <!ATTLIST titre2 %titre.attributs; >
        
        <!ELEMENT titre3 (%fragmentDeTexteAvecNoteBP;)* >
        <!ATTLIST titre3 %titre.attributs; >
        
        <!ELEMENT titre4 (%fragmentDeTexteAvecNoteBP;)* >
        <!ATTLIST titre4 %titre.attributs; >
        
        <!ELEMENT titre5 (%fragmentDeTexteAvecNoteBP;)* >
        <!ATTLIST titre5 %titre.attributs; >
        
        <!ELEMENT paragraphe (%fragmentDeTexteAvecNoteBP; | index)* >
        
        <!ELEMENT noteBP (%fragmentDeTexte;)* >
        
        <!ELEMENT remarque (%fragmentDeTexteAvecNoteBP; | index)* >
        <!ATTLIST remarque     id       ID    #REQUIRED
                               titre    CDATA #REQUIRED
        >
        
        <!ELEMENT figure EMPTY >
        <!ATTLIST figure      id       ID    #REQUIRED
                              dir      CDATA #IMPLIED
                              file     CDATA #REQUIRED
                              legende  CDATA #REQUIRED
        >
        
        <!ELEMENT listing (%elementDeListing;)* >
        <!ELEMENT listingRTF (%elementDeListing;)* >
        <!ELEMENT listingAvecTitre (%elementDeListing;)* >
        <!ELEMENT listingPseudoCode (%elementDeListing;)* >
        
        <!ELEMENT codeUneLigne (#PCDATA) >
        
        <!ELEMENT fichier  EMPTY >
        <!ATTLIST fichier  nom CDATA #REQUIRED >
        
        <!ELEMENT ligneCodeAvecCommentaire  (#PCDATA) >
        
        <!ELEMENT commentaireLigneDeCode  (%fragmentDeTexteAvecNoteBP;)* >
        
        <!ELEMENT titreCode  (#PCDATA) >
        
        <!ELEMENT sousTitreCommentaire  (#PCDATA) >
        
        <!ELEMENT exemplePourSousTitreDeCommentaire  (#PCDATA) >
        
        <!ELEMENT listeANumero  ( item | liste2 )+ >
        <!ELEMENT liste  ( item | liste2 )+ >
        <!ELEMENT liste2  ( item )+ >
        <!ELEMENT item  (%fragmentDeTexteAvecNoteBP;)* >
        <!ATTLIST item  no CDATA #IMPLIED >
        
        <!ELEMENT tableau  ( legende?, titresColonnes, lignes+ ) >
        <!ATTLIST tableau  id       ID   #IMPLIED >
        
        <!ELEMENT tableauSansTitresColonnes  ( legende?, lignes+ ) >
        <!ATTLIST tableauSansTitresColonnes  id       ID   #IMPLIED >
                           
        <!ELEMENT titresColonnes  ( cellule | nouvelleCellule )* >
        <!ELEMENT lignes          ( cellule | nouvelleCellule | 
                                              nouvelleLigne )* >
        <!ELEMENT legende  (%fragmentDeTexte;)* >
        <!ELEMENT cellule  (%fragmentDeTexteAvecNoteBP; | celbr)* >
        <!ELEMENT nouvelleCellule  EMPTY >
        <!ELEMENT nouvelleLigne    EMPTY >
        <!ELEMENT celbr            EMPTY >
        
        
        
<!--  ================================================================== -->
    


<!--  =========================  -->
<!--   Qu'est-ce qu'un livre ?   -->
<!--  =========================  -->

<!ELEMENT livre ( partie | chapitre )* >
<!ELEMENT chapitre (%blocDeTexte;)* >

<!--  ==================  -->
<!--         fin          -->
<!--  ==================  -->
<!-- ] -->

Transformation XSLT

Prologue

<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet 
    xmlns:xsl = "http://www.w3.org/1999/XSL/Transform" 
    xmlns:saxon="http://icl.com/saxon"
    extension-element-prefixes="saxon"
    version   = "1.0">
        

    <xsl:strip-space elements="*"/>
    <xsl:output  method='text' encoding='ISO-8859-1' />
    
<xsl:template match='/'>
    <xsl:text>
    <xsl:text>{\rtf1\ansi\ansicpg1252\uc1 \deff0\deflang1036\deflangfe1036{\fonttbl{\f0\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times New Roman;}{\f1\fswiss\fcharset0\fprq2{\*\panose 020b0604020202020204}Arial;}
{\f2\fmodern\fcharset0\fprq1{\*\panose 02070309020205020404}Courier New;}{\f3\froman\fcharset2\fprq2{\*\panose 05050102010706020507}Symbol;}{\f4\froman\fcharset0\fprq2{\*\panose 02020603050405020304}Times;}
{\f14\fnil\fcharset2\fprq2{\*\panose 05000000000000000000}Wingdings;}{\f28\fswiss\fcharset0\fprq2{\*\panose 020b0506020202030204}Arial Narrow;}

... etc ...

{\field{\*\fldinst {\b  SECTIONPAGES  \* MERGEFORMAT }}{\fldrslt {\b\lang1024\langfe1024\noproof 5}}}{
\par }}{\*\pnseclvl1\pnucrm\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl2\pnucltr\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl3\pndec\pnstart1\pnindent720\pnhang{\pntxta .}}{\*\pnseclvl4\pnlcltr\pnstart1\pnindent720\pnhang{\pntxta )}}
{\*\pnseclvl5\pndec\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl6\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl7\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl8
\pnlcltr\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}{\*\pnseclvl9\pnlcrm\pnstart1\pnindent720\pnhang{\pntxtb (}{\pntxta )}}
</xsl:text>
</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:apply-templates/>
    }
    
</xsl:template>

Règles pour la transcription RTF d'un style

    <!--
    ==== subtil ======
    --> 
    
<xsl:template match='subtil'>
    <xsl:text>{\cs59\i </xsl:text>
    <xsl:apply-templates mode='noTrim'/>
    <xsl:text>}</xsl:text>
</xsl:template>

    <!--
    ==== italiques ======
    --> 
    
<xsl:template match='italiques'>
    <xsl:text>{\i </xsl:text>
    <xsl:apply-templates mode='noTrim'/>
    <xsl:text>}</xsl:text>
</xsl:template>

    <!--
    ==== pseudoCode ======
    --> 
    
<xsl:template match='pseudoCode' mode='listing'>
    <xsl:text>{\cs78\i </xsl:text>
    <xsl:apply-templates mode='listing'/>
    <xsl:text>}</xsl:text>
</xsl:template>

    <!--
    ==== titreOeuvre ======
    --> 
    
<xsl:template match='titreOeuvre'>
    <xsl:text>{\cs62\i </xsl:text>
    <xsl:apply-templates mode='noTrim'/>
    <xsl:text>}</xsl:text>
</xsl:template>
    
    <!--
    ==== très important ===
    --> 
    
<xsl:template match='tresImportant'>
    <xsl:text>{\cs60\b </xsl:text>
    <xsl:apply-templates mode='noTrim'/>
    <xsl:text>}</xsl:text>
</xsl:template>
    <!--
    ==== remarque =========================================
    --> 
    
<xsl:template match='remarque'>
    <xsl:text>
\pard\plain \s40\qj \li1418\ri0\sb160\widctlpar\tx1418\aspalpha\aspnum\faauto\adjustright\rin0\lin1418\itap0 \b\f28\fs18\lang3084\langfe1036\cgrid\langnp3084\langfenp1036 {
{\*\bkmkstart </xsl:text>
    <xsl:value-of select="translate( @id, '.-_', '')"/>
    <xsl:text>}</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:value-of select="@titre"/>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:text>{\*\bkmkend </xsl:text>
    <xsl:value-of select="translate( @id, '.-_', '')"/>
    <xsl:text>}
\par }
\pard\plain \s39\qj \li1418\ri0\sb40\widctlpar
\tx1418\aspalpha\aspnum\faauto\adjustright\rin0\lin1418\itap0 \fs18\lang3084\langfe1036\cgrid\langnp3084\langfenp1036{</xsl:text>
    <xsl:apply-templates/>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:text>\par }</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>

</xsl:template>
    <!--
    ==== titre niveau 2 =========================================
    --> 
    
<xsl:template match='titre2'>
    <xsl:text>
\pard\plain \s2\ql \li0\ri0\sb500\keep\keepn\widctlpar\aspalpha\aspnum\faauto\outlinelevel1\adjustright\rin0\lin0\itap0 \b\f1\fs28\lang1024\langfe1024\cgrid\noproof\langnp1036\langfenp1036
{
{\*\bkmkstart </xsl:text>
    <xsl:value-of select="translate( @id, '.-_', '')"/>
    <xsl:text>}</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:apply-templates/>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:text>{\*\bkmkend </xsl:text>
    <xsl:value-of select="translate( @id, '.-_', '')"/>
    <xsl:text>}</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:if test="@indexWords">
        <xsl:call-template name="instancier-XEntries">
            <xsl:with-param name="listOfNumbers" select="@indexWords"/>
            <xsl:with-param name="stringToSplit" select="normalize-space(.)"/>
        </xsl:call-template>
    </xsl:if>
    <xsl:call-template name="instancier-sautDeLigne"/>
    <xsl:text>\par }</xsl:text>
    <xsl:call-template name="instancier-sautDeLigne"/>
    
</xsl:template>
    <!--
    ***************************************************************************
    -->
    <titre4 id="importSemantiqueinter.titre.14.Decoupe" indexWords="1,4,5"> Intérêt de l'instruction xsl:import</titre4>
{\xe \v{Intérêt de l'instruction xsl:import}}
{\xe \v{instruction xsl:import (Intérêt de l')}}
{\xe \v{xsl:import (Intérêt de l'instruction )}}

Règles pour rendre inoffensifs certains caractères en RTF

        
    <!--
    ==== text  =========================================
    --> 
    

<xsl:template match='text()'>
    <xsl:call-template name="instancier-texteAvec-escape-accolades">
        <xsl:with-param name="texte" select="normalize-space(.)" />
    </xsl:call-template>
</xsl:template>
    
    <!-->
    ================================================
    <!-->

<xsl:template match='text()' mode='noTrim'>
    <xsl:call-template name="instancier-texteAvec-escape-accolades">
        <xsl:with-param name="texte" select="." />
    </xsl:call-template>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template match='text()' mode='listing'>
    <xsl:call-template name="instancier-texteAvec-RTFpar-et-escape-accolades">
        <xsl:with-param name="texte" select="translate(.,'<>','&lt;>')" />
    </xsl:call-template>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template match='text()' mode='listingRTF'>
    <xsl:call-template 
    name="instancier-texteAvec-RTFpar-et-escape-accolades-et-backslash">
    
        <xsl:with-param name="texte" select="translate(.,'<>','&lt;>')" />
    </xsl:call-template>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name="instancier-texteAvec-escape-accolades">
    <xsl:param name="texte" />
    
    <xsl:variable name="codeSource2">
        <xsl:call-template name="instancier-texteAvec-escape-accolades-gauches">
            <xsl:with-param name="codeSource" select="$texte" />
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:variable name="codeSource3">
        <xsl:call-template name="instancier-texteAvec-escape-accolades-droites">
            <xsl:with-param name="codeSource" select="$codeSource2" />
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:copy-of select="$codeSource3"/>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name='instancier-texteAvec-RTFpar-et-escape-accolades'>
    <xsl:param name="texte" />
    
    <xsl:variable name="codeSource1">
        <xsl:call-template name="instancier-texteAvec-RTFpar">
            <xsl:with-param name="codeSource" select="$texte" />
        </xsl:call-template>
    </xsl:variable>
    
    
    <xsl:variable name="codeSource3">
        <xsl:call-template name="instancier-texteAvec-escape-accolades">
            <xsl:with-param name="texte" select="$codeSource1" />
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:copy-of select="$codeSource3"/>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template 
name='instancier-texteAvec-RTFpar-et-escape-accolades-et-backslash'>

    <xsl:param name="texte" />
            
    <xsl:variable name="codeSource3">
        <xsl:call-template name="instancier-texteAvec-escape-backslash">
            <xsl:with-param name="codeSource" select="$texte" />
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:variable name="codeSource1">
        <xsl:call-template 
        name="instancier-texteAvec-RTFpar-et-escape-accolades">
        
            <xsl:with-param name="texte" select="$codeSource3" />
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:copy-of select="$codeSource1"/>
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
             
    
<xsl:template name="instancier-texteAvec-RTFpar">
    <xsl:param name="codeSource" />
    <xsl:choose>
        <xsl:when test="contains( $codeSource, '&#xa;' )">
            <xsl:value-of select="substring-before( $codeSource, '&#xa;' )" />
            <xsl:call-template name="instancier-sautDeLigne"/>
            <xsl:text>\par </xsl:text>
            <xsl:call-template name="instancier-texteAvec-RTFpar">
                <xsl:with-param name="codeSource" 
                                select="substring-after($codeSource,'&#xa;')"/>
            </xsl:call-template>
        </xsl:when>
        
        <xsl:otherwise>
            <xsl:value-of select="$codeSource" />
        </xsl:otherwise>
    </xsl:choose>
</xsl:template> 
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name="instancier-texteAvec-escape-backslash">
    <xsl:param name="codeSource" />
    <xsl:choose>
        <xsl:when test="contains( $codeSource, '\' )">
            <xsl:value-of select="substring-before( $codeSource, '\' )" />
            <xsl:text>\</xsl:text>
            <xsl:call-template name="instancier-texteAvec-escape-backslash">
                <xsl:with-param name="codeSource" 
                                select="substring-after($codeSource, '\' )" />
            </xsl:call-template>
        </xsl:when>
        
        <xsl:otherwise>
            <xsl:value-of select="$codeSource"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template> 
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name="instancier-texteAvec-escape-accolades-gauches">
    <xsl:param name="codeSource" />
    <xsl:choose>
        <xsl:when test="contains( $codeSource, '{' )">
            <xsl:value-of select="substring-before( $codeSource, '{' )" />
            <xsl:text>\{</xsl:text>
            <xsl:call-template 
            name="instancier-texteAvec-escape-accolades-gauches">
                <xsl:with-param name="codeSource" 
                                select="substring-after($codeSource, '{' )" />
            </xsl:call-template>
        </xsl:when>
        
        <xsl:otherwise>
            <xsl:value-of select="$codeSource"/>
        </xsl:otherwise>
    </xsl:choose>
</xsl:template>
        
    <!-->
    ================================================
    <!-->
    
    <xsl:template name="instancier-texteAvec-escape-accolades-droites">
        <xsl:param name="codeSource" />
        <xsl:choose>
            
            <xsl:when test="contains( $codeSource, '}' )">
                <xsl:value-of select="substring-before( $codeSource, '}' )" />
                <xsl:text>\}</xsl:text>
                <xsl:call-template 
                name="instancier-texteAvec-escape-accolades-droites">
                    <xsl:with-param name="codeSource" 
                                    select="substring-after($codeSource,'}')"/>
                </xsl:call-template>
            </xsl:when>
            
            <xsl:otherwise>
                <xsl:value-of select="$codeSource"/>
            </xsl:otherwise>
        </xsl:choose>
</xsl:template>
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name="instancier-sautDeLigne">
    <xsl:text>
</xsl:text>
</xsl:template>

Entrées d'index

<xsl:template name="instancier-XEntry">
    <xsl:param name="blankNumber"/>
    <xsl:param name="stringToSplit"/>
    
    <xsl:variable name="before_after">
        <xsl:call-template name="instancier-stringSplits">
            <xsl:with-param name="blankNumber" select="$blankNumber"/>
            <xsl:with-param name="stringToSplit" select="$stringToSplit"/>
        </xsl:call-template>
    </xsl:variable>
    
    <xsl:variable name="wordsBefore">
        <xsl:value-of select="$before_after//before" />
    </xsl:variable>
    
    <xsl:variable name="wordsBefore-paren">
    
        <xsl:choose>
            <xsl:when test="normalize-space($wordsBefore)">
                (<xsl:value-of select="$wordsBefore" />)
            </xsl:when>
            
            <xsl:otherwise>
            </xsl:otherwise>
        </xsl:choose>
                
    </xsl:variable>

    <xsl:variable name="wordsAfter">
        <xsl:value-of select="$before_after//after" />
    </xsl:variable>
    
    <xsl:variable name="theEntry">
        <xsl:value-of select="$wordsAfter"/><xsl:text> </xsl:text>
        <xsl:value-of select="$wordsBefore-paren"/> 
    </xsl:variable>
    
    <xsl:call-template name="instancier-indexEntry">
        <xsl:with-param name="entry" select="$theEntry"/>
    </xsl:call-template>
                
</xsl:template>

    
    <!-->
    ================================================
    <!-->    
    
<xsl:template name="instancier-XEntries">
    <xsl:param name="listOfNumbers"/>
    <xsl:param name="stringToSplit"/>
    
    <xsl:choose>
        <xsl:when test="contains($listOfNumbers, ',')">
    
            <xsl:variable name="aNumber">
                <xsl:value-of select="substring-before( $listOfNumbers, ',')"/>
            </xsl:variable>
    
            <xsl:call-template name="instancier-XEntry">
                <xsl:with-param name="blankNumber" select="$aNumber - 1"/>
                <xsl:with-param name="stringToSplit" select="$stringToSplit"/>
            </xsl:call-template>
            <xsl:call-template name="instancier-XEntries">
                <xsl:with-param name="listOfNumbers" 
                                select="substring-after($listOfNumbers, ',')"/>
                <xsl:with-param name="stringToSplit" select="$stringToSplit"/>
            </xsl:call-template>
            
        </xsl:when>
        
        <xsl:otherwise>
        
            <xsl:if test="$listOfNumbers">
            
                <xsl:choose>
                    <xsl:when test="number($listOfNumbers) = 1">
                        <xsl:call-template name="instancier-indexEntry">
                            <xsl:with-param name="entry" 
                                            select="$stringToSplit"/>
                        </xsl:call-template>
                    </xsl:when>
                    
                    <xsl:otherwise>
                        <xsl:call-template name="instancier-XEntry">
                            <xsl:with-param name="blankNumber" 
                                            select="number($listOfNumbers)-1"/>
                            <xsl:with-param name="stringToSplit" 
                                            select="$stringToSplit"/>
                        </xsl:call-template>
                    </xsl:otherwise>
                </xsl:choose>
                
            </xsl:if>
            
        </xsl:otherwise>
    </xsl:choose>
        
</xsl:template>
    
    
    <!-->
    ================================================
    <!-->
    
<xsl:template name="instancier-indexEntry">
    <xsl:param name="entry"/>
    <xsl:text>{\xe \v{</xsl:text>
    <xsl:value-of select="normalize-space($entry)"/>
    <xsl:text>}}</xsl:text>
</xsl:template>
    
    <!-->
    ================================================
    <!-->
    
<xsl:template match='index'>
        
    <xsl:variable name="wordNumbers">
        <xsl:value-of select="@indexWords"/> 
    </xsl:variable>
    
    <xsl:variable name="entries">
        <xsl:value-of select="."/> 
    </xsl:variable>
    
    
    <xsl:choose>
    
        <!-- cas où il y a une liste de numéros de mots -->
        <xsl:when test="normalize-space($wordNumbers)">
    
    
            <xsl:call-template name="instancier-XEntries">
                <xsl:with-param name="listOfNumbers" select="$wordNumbers"/>
                <xsl:with-param name="stringToSplit" 
                                select="normalize-space($entries)"/>
            </xsl:call-template>
        </xsl:when>
        
        <!-- cas où il n'y a pas de liste de numéros de mots :    --> 
        <!-- le contenu constitue l'entrée d'index                -->
        <xsl:otherwise>
            <xsl:variable name="theEntry">
                <xsl:apply-templates/> 
            </xsl:variable>
            <xsl:call-template name="instancier-indexEntry">
                <xsl:with-param name="entry" 
                                select="normalize-space($theEntry)"/>
            </xsl:call-template>
        </xsl:otherwise>
        
    </xsl:choose>
        
</xsl:template>
<xsl:template  name="instancier-stringSplits">
    <xsl:param name="blankNumber"/>
    <xsl:param name="stringToSplit"/>
            
    <xsl:choose>
    
        <!-- = -->
        <!-- = -->
        <xsl:when test="$blankNumber = 1">
        
            <xsl:variable name="result">
                <xsl:call-template 
                name="stringSplits-beforeAndAfter-firstSeparator">
                
                    <xsl:with-param name="stringToSplit" 
                                    select="$stringToSplit"/>
                                    
                </xsl:call-template>
            </xsl:variable>
            
            <xsl:copy-of select="$result" />
            
        </xsl:when>
        
        <!-- = -->
        <!-- = -->
        <xsl:when test="$blankNumber = 0">
        
            <xsl:variable name="result">
                <split>
                    <before/>
                    <after>
                        <xsl:value-of select="$stringToSplit" />
                    </after>
                </split>
            </xsl:variable>
            
            <xsl:copy-of select="$result" />
            
        </xsl:when>
        
        <!-- = -->
        <!-- = -->
        <xsl:otherwise>
            
            <!-- = -->
            <xsl:variable name="before_after">
                <xsl:call-template 
                name="stringSplits-beforeAndAfter-firstSeparator">
                
                    <xsl:with-param name="stringToSplit" 
                                    select="$stringToSplit"/>
                                    
                </xsl:call-template>
            </xsl:variable>
            
            <!-- = -->
            <xsl:variable name="before">
                <xsl:value-of select="$before_after//before" />
            </xsl:variable>
            
            <!-- = -->
            <xsl:variable name="separator">
                <xsl:value-of select="$before_after//separator" />
            </xsl:variable>
            
            <!-- = -->
            <xsl:variable name="after">
                <xsl:value-of select="$before_after//after" />
            </xsl:variable>
            
            <!-- = -->
            <xsl:variable name="recursive_before_after">
                <xsl:call-template name="instancier-stringSplits">
                    <xsl:with-param name="blankNumber" 
                                    select="number($blankNumber)-1"/>
                    <xsl:with-param name="stringToSplit" select="$after"/>
                </xsl:call-template>
            </xsl:variable>
            
            <!-- = -->
            <xsl:variable name="result">
                <split>
                    <before>
                        <xsl:value-of select="concat( $before, 
                                            $recursive_before_after//before)"/>
                    </before>
                    <after>
                        <xsl:value-of select="$recursive_before_after//after"/>
                    </after>
                </split>
            </xsl:variable>
            
            <!-- = -->
            <xsl:copy-of select="$result" />
            
        </xsl:otherwise>
        
    </xsl:choose>
    
</xsl:template>

Feuille de style complète

preceding-sibling::*[1] Table following-sibling::*[1]