Annexe II - Les instruction ménagères
        Instruction xsl:stylesheet
                Syntaxe
                Variantes syntaxiques
                        Attribut extension-element-prefixes
                        Attribut exclude-result-prefixes
        Instruction xsl:namespace-alias
                Syntaxe
                Sémantique
        Instruction xsl:fallback
                Syntaxe
                Instruction XSLT typique
        Instruction xsl:preserve-space
Instruction xsl:strip-space

                Syntaxe
                Sémantique
        Instruction xsl:output
                Syntaxe
                Sémantique
        Instruction xsl:decimal-format
                Syntaxe
                Sémantique
                Exemple


Annexe II - Les instruction ménagères

Instruction xsl:stylesheet

Syntaxe

xsl:stylesheet
<xsl:stylesheet         
    version="1.0"
/>
xsl:transform
<xsl:transform         
    version="1.0"
/>

Variantes syntaxiques

xsl:stylesheet
<xsl:stylesheet         
    version="1.0"
    extension-element-prefixes="... ... ..."
    exclude-result-prefixes="... ... ..."
/>

Attribut extension-element-prefixes

Saison.xsl
<?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:output  method='html' encoding='ISO-8859-1' />
    
    <xsl:template match="/">
        <html>
            <head>
                <title>Programme Saison 
                <xsl:value-of 
                select="/Saison/Période"/></title>
            </head>
            <body bgcolor="white" text="black">
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="Saison">
        <xsl:apply-templates select="Manifestations"/>
        <H3>Adresses :</H3> 
        <xsl:apply-templates select="Adresse"/>
    </xsl:template>
    
    <xsl:template match="Concert|Théâtre">
        <H3><xsl:value-of select="local-name(.)"/> </H3>
        <p><saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           Date : <xsl:value-of select="Date"/> <br/>
           <saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           <saxon:entity-ref name="nbsp"/>
           Lieu : <a href="#{generate-id(
                             /Saison/Adresse/Lieu
                             [ . = current()/Lieu ])}">
                   <xsl:value-of select="Lieu"/>
                   </a>
        </p>
    </xsl:template>
    
    <xsl:template match="Adresse">
        <p><a name="#{generate-id(./Lieu)}">
        <xsl:value-of select="Lieu"/></a><br/>
        <xsl:value-of select="./child::text()[2]"/>
        </p>
    </xsl:template>
    
    <xsl:template match="text()"/>
 
    
</xsl:stylesheet>   
Saison.html
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   
      <title>Programme Saison  Automne 1999 </title>
   </head>
   <body bgcolor="white" text="black">
      <H3>Concert</H3>
      <p>&nbsp;&nbsp;&nbsp;&nbsp;
               Date : Samedi 9 Octobre 1999  20H30  <br>
               &nbsp;&nbsp;&nbsp;&nbsp;
               Lieu : <a href="#d0e56">Chapelle des Ursules</a></p>
      <H3>Th&eacute;&acirc;tre</H3>
      <p>&nbsp;&nbsp;&nbsp;&nbsp;
               Date : Mardi 19 Novembre 1999  21H  <br>
               &nbsp;&nbsp;&nbsp;&nbsp;
               Lieu : <a href="#d0e62">Salle des Cordeliers</a></p>
      <H3>Th&eacute;&acirc;tre</H3>
      <p>&nbsp;&nbsp;&nbsp;&nbsp;
               Date : Mercredi 20 Novembre 1999  21H30  <br>
               &nbsp;&nbsp;&nbsp;&nbsp;
               Lieu : <a href="#d0e62">Salle des Cordeliers</a></p>
      <H3>Adresses :</H3>
      <p><a name="#d0e56">Chapelle des Ursules</a><br>
                9, rue des Ursules - 49000 Angers
            
      </p>
      <p><a name="#d0e62">Salle des Cordeliers</a><br>
                1, rue des Pr&eacute;voyants de l'avenir - 49000 Angers
            
      </p>
   </body>
</html>

Attribut exclude-result-prefixes

<truc bidule="machin:chose">

Instruction xsl:namespace-alias

Syntaxe

xsl:namespace-alias
<xsl:namespace-alias
    stylesheet-prefix="..."
    result-prefix="..."
/>

Sémantique

<xsl:namespace-alias 
    stylesheet-prefix="mm" 
    result-prefix="tt"/>
Concert.xml
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>

<Concert>
    
    <Date>Jeudi 17 Janvier 2002, 20H30</Date>
    <Lieu>Chapelle des Ursules</Lieu>

    <Interprètes>
        <Interprète>
            <Nom> Jonathan Dunford </Nom>
            <Instrument>Basse de viole</Instrument>
        </Interprète>
    
        <Interprète>
            <Nom> Sylvia Abramowicz </Nom>
            <Instrument>Basse de viole</Instrument>
        </Interprète>
    </Interprètes>

</Concert>
Concert.xsl
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet 
    
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:mm="http://machin" 
    xmlns:tt="http://truc"
    version="1.0">

    <xsl:output  method='xml' encoding='ISO-8859-1' indent='yes' />
    
    <xsl:namespace-alias stylesheet-prefix="mm" result-prefix="tt"/>

    <xsl:template match="Interprètes">
        <mm:Musiciens>
        <xsl:copy-of select="Interprète"/>
        </mm:Musiciens>
    </xsl:template>
    
    <xsl:template match="text()"></xsl:template>
    
</xsl:stylesheet>
Résultat
<?xml version="1.0" encoding="ISO-8859-1"?>
<mm:Musiciens xmlns:mm="http://truc" xmlns:tt="http://truc">
   <Interprète>
            
      <Nom> Jonathan Dunford </Nom>
            
      <Instrument>Basse de viole</Instrument>
        
   </Interprète>
   <Interprète>
            
      <Nom> Sylvia Abramowicz </Nom>
            
      <Instrument>Basse de viole</Instrument>
        
   </Interprète>
</mm:Musiciens>

Instruction xsl:fallback

Syntaxe

xsl:fallback
<xsl:fallback>
    <!-- modèle de transformation -->
</xsl:fallback>

Instruction XSLT typique

<xsl:xxx>
    <!-- modèle de transformation propre à xsl:xxx -->
    <xsl:fallback>
        <!-- modèle de transformation propre à xsl:fallback -->
    </xsl:fallback>
</xsl:xxx>

Instruction xsl:preserve-space
Instruction xsl:strip-space

Syntaxe

xsl:preserve-space
<xsl:preserve-space elements="... ... ..."/>
xsl:strip-space
<xsl:strip-space elements="... ... ..."/>

Sémantique

<xsl:strip-space elements="*"/>
<xsl:preserve-space elements="truc bidule"/>

Instruction xsl:output

Syntaxe

xsl:output
<xsl:output 
    method = "..."  <!-- "xml" | "html" | "text" | name -->
    version = "..."
    encoding = "..."
    omit-xml-declaration = "..." <!-- "yes" | "no" -->
    standalone = "..." <!-- "yes" | "no" -->
    doctype-public = "..." <!-- string -->
    doctype-system = "..." <!-- string -->
    cdata-section-elements = "... ... ..."
    indent = "..." <!-- "yes" | "no" -->
    media-type = "..." <!-- string --> 
/>

Sémantique

Instruction xsl:decimal-format

Syntaxe

xsl:decimal-format
<xsl:decimal-format
    
    name = "..."
    decimal-separator = "..."  <!-- char -->
    grouping-separator = "..." <!-- char --> 
    infinity = "..." <!-- string -->
    minus-sign = "..." <!-- char --> 
    NaN = "..." <!-- string -->
    percent = "..." <!-- char --> 
    per-mille = "..." <!-- char --> 
    zero-digit = "..." <!-- char --> 
    digit = "..." <!-- char --> 
    pattern-separator = "..." <!-- char -->  
/>

Sémantique

Exemple

Concert.xml
<?xml version="1.0" encoding="UTF-16" standalone="yes"?>

<Concert>
    
    <Entête> "Les Concerts d'Anacréon" </Entête>
    <Date>Jeudi 17 Janvier 2002, 20H30</Date>
    <Lieu>Chapelle des Ursules</Lieu>

    <Ensemble> "A deux violes esgales" </Ensemble>
    
    <Compositeurs>
        <Compositeur>M. Marais</Compositeur>
        <Compositeur>D. Castello</Compositeur>
        <Compositeur>F. Rognoni</Compositeur>
    </Compositeurs>

    <Tarif>
        <plein> 15.0 </plein>
        <réductions>
            <jeune>40</jeune>
            <groupe>30</groupe>
        </réductions>
    </Tarif>
    
</Concert>
Concert.xsl
<?xml version="1.0" encoding="UTF-16"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">

    <xsl:output  method='html' encoding='ISO-8859-1' />
    
    <xsl:template match="/">
        <html>
            <head>
                <title><xsl:value-of select="/Concert/Entête"/></title>
            </head>
            <body bgcolor="white" text="black">
                <xsl:apply-templates/>
            </body>
        </html>
    </xsl:template>
    
    <xsl:template match="Date">
        <H1 align="center"> Concert du <xsl:value-of select="."/> </H1>
        <H4 align="center"> <xsl:value-of select="/Concert/Lieu"/> </H4>
        <H3 align="center"> <xsl:value-of select="/Concert/TitreConcert"/></H3>
    </xsl:template>
    
    <xsl:template match="Lieu">
    </xsl:template>
    
    <xsl:template match="Ensemble">
        <H2 align="center"> Ensemble <xsl:value-of select="."/></H2>
    </xsl:template>

    <xsl:decimal-format 
        name="prix" 
        decimal-separator="," 
        grouping-separator="." />
    
    <xsl:template match="Tarif">
        <xsl:variable name="plein" select="./plein"/>
        <xsl:variable name="reducJeune" select="./réductions/jeune"/>
        <xsl:variable name="reducGroupe" select="./réductions/groupe"/>
        
        <xsl:variable 
            name="jeune" 
            select="$plein - ( $plein * $reducJeune div 100 ) "/>
            
        <xsl:variable 
            name="groupe" 
            select="$plein - ( $plein * $reducGroupe div 100 ) "/>
        
        <P>Tarifs : <br/>
        <xsl:value-of select="format-number( 
                      $plein, '##,00', 'prix' )"/> Euros <br/>
                      
        <xsl:value-of select="format-number( 
                      $jeune, '##,00', 'prix' )"/> Euros (jeunes),<br/>
                      
        <xsl:value-of select="format-number( 
                      $groupe, '##,00', 'prix' )"/> Euros (groupes).
        </P>
    </xsl:template>
    
    
</xsl:stylesheet>
Résultat
<html>
   <head>
      <meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
   
      <title> "Les Concerts d'Anacr&eacute;on" </title>
   </head>
   <body bgcolor="white" text="black">
        
         "Les Concerts d&#8217;Anacr&eacute;on" 
        
      <H1 align="center"> Concert du Jeudi 17 Janvier 2002, 20H30</H1>
      <H4 align="center">Chapelle des Ursules</H4>
      <H3 align="center"></H3>
        
      <H2 align="center"> Ensemble  "A deux violes esgales" </H2>
        
            M. Marais
            D. Castello
            F. Rognoni
        
      <P>Tarifs : <br>15,00 Euros <br>9,00 Euros (jeunes),<br>10,50 Euros (groupes).
      </P>
   </body>
</html>
preceding-sibling::*[1] Table following-sibling::*[1]