Re: tri fichier par un xsl

Eric van der Vlist <[email protected]>
Newsgroups gmane.text.xml.french.tech
Organization Dyomedea (http://dyomedea.com)
Message-ID <[email protected]>
Bonjour,
Le jeudi 13 avril 2006 à 11:42 +0200, Jacob Bizzoire a écrit :
> Bonjour,
> Etant un nouveau utilisateur de la techno xml et cocoon en particulier, je 
> rencontre un probléme surement basique sur mon fichier xsl. Le fichier xsl 
> ne me renvoie rien.
> Je veux trier le fichier par ordre alphabétique suivant l'élément label. Si 
> quelqu'un a une idée...
> 
> mon xsl:
> <xsl:stylesheet version="1.0"
> 	xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
> 	xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
> 	<xsl:template match="/">
> 	<xsl:apply-templates select="fd:selection-list" />
> 	</xsl:template>
> 	<xsl:template match="fd:selection-list">
> 		<xsl:for-each select="fd:item/fd:label">
> 			<xsl:sort select="." />
> 		</xsl:for-each>
> 	</xsl:template>
> </xsl:stylesheet>

Votre transformation XSLT (et son tri) sont corrects mais vous ne leur
demandez pas de générer quoique ce soit :-) ...

Personnellement, j'écrirais:

<xsl:stylesheet version="1.0"
        xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
        xmlns:fd="http://apache.org/cocoon/forms/1.0#definition">
        <xsl:template match="*|node()">
           <xsl:copy>
             <xsl:apply-templates select="@*|node()"/>
           </xsl:copy>
        </xsl:template>
        <xsl:template match="fd:selection-list">
           <xsl:copy>
               <xsl:apply-templates select="fd:item">
                   <xsl:sort select="fd:label" />
               </xsl:apply-templates>
        </xsl:template>
</xsl:stylesheet>

(non testé, peut contenir des erreurs de frappe).

Cordialement,

Eric van der Vlist

-- 
GPG-PGP: 2A528005
Did you know it? Python has now a Relax NG (partial) implementation.
                                          http://advogato.org/proj/xvif/
------------------------------------------------------------------------
Eric van der Vlist       http://xmlfr.org            http://dyomedea.com
(ISO) RELAX NG   ISBN:0-596-00421-4 http://oreilly.com/catalog/relax
(W3C) XML Schema ISBN:0-596-00252-1 http://oreilly.com/catalog/xmlschema
------------------------------------------------------------------------


-- Attached file included as plaintext by Ecartis --

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.1 (GNU/Linux)

iD8DBQBEPh+kDvn+ZCpSgAURAuyRAKCY4mAcOOhQ8gx71Ckj7rC6uDM+DwCghGnb
i2oDFiehp8KPOhrOQg0e4J4=
=mPOH
-----END PGP SIGNATURE-----
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.