Le vendredi 23 septembre 2005 à 10:51 +0200, Stéphane Bonhomme a écrit :
> En effet, et la solution est encore plus simple,
>
> sur votre exemple, le xsl suivant :
>
> <xsl:stylesheet xmlns:xsl = "http://www.w3.org/1999/XSL/Transform"
> version="1.0">
> <xsl:output method="xml" indent="yes"/>
>
> <xsl:template match="root|A">
> <xsl:copy>
> <xsl:copy-of select="@id"/>
> <xsl:apply-templates/>
> </xsl:copy>
> </xsl:template>
> </xsl:stylesheet>
>
Cela ne fonctionne que parce qu'il n'y a pas d'éléments contenant du
texte dans cet exemple simpliste.
Si le document de départ était :
<root>
<A id="context">
<foo>
<bar>mon texte</bar>
<A id="1">
<A id="1.1"/>
<bar>
<A id="1.2"/>
</bar>
</A>
</foo>
<A id="2"/>
<fred>
<waldo>
<A id="3">
<A id="3.1"/>
</A>
</waldo>
</fred>
</A>
</root>
Votre <xsl:apply-templates/> appliquerait le template par défaut à
l'élément "bar" et vous récupéreriez le noeud texte "mon texte" dans
voter résultat.
Pur éviter cela il faut redéfinir le template par défaut comme :
<xsl:template match="*">
<xsl:apply-templates/>
</xsl:template>
Cordialement,
Eric van der Vlist
--
If you have a XML document, you have its schema.
http://examplotron.org
------------------------------------------------------------------------
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
------------------------------------------------------------------------
|
Try Searching:
servers, voip, java, networking, microsoft ...
|
|
|
|