From: Benoît Barré (benoitbarre@free.fr)
Date: 01/09/2003 - 16:29
Selon Testud David <david.testud@ledl.com>:
>
> Bonjour à tous,
>
> Soit le xml suivant :
> *********************
> <PARTIE>
> <TITRE>Titre 1</TITRE>
> blah1...blah1...blah1...
> <TITRE>Titre 2</TITRE>
> blah2...blah2...blah2...
> <TITRE>Titre 3</TITRE>
> blah3...blah3...blah3...
> </PARTIE>
>
> Je voudrais le transformer via une xslt en :
> ********************************************
> <PARTIE>
> <TITRE>Titre 1</TITRE>
> <ARTICLE>blah1...blah1...blah1...</ARTICLE>
> <TITRE>Titre 2</TITRE>
> <ARTICLE>blah2...blah2...blah2...</ARTICLE>
> <TITRE>Titre 3</TITRE>
> <ARTICLE>blah3...blah3...blah3...</ARTICLE>
> </PARTIE>
>
> Voilà quelques heures que je me casse la tête avec XPath alors n'auriez vous
> pas un petit coup de pouce à me donner ? J'ai cru un instant que c'était
> simple à faire...
> ;o)
> Merci pour votre aide...
>
> Cordialement,
>
> David
>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="*|@*">
<xsl:copy>
<xsl:apply-templates select="text()|*|@*"/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()[parent::PARTIE]"><ARTICLE><xsl:value-of
select="."/></ARTICLE></xsl:template>
</xsl:stylesheet>
bB
--
Devenez redacteur <XML>fr et contribuez au developpement du
xml francophone (http://xmlfr.org/infos/redacteurs/) !
Liste de diffusion "xml-tech@xmlfr.org" (http://xmlfr.org).
Cette liste est a votre disposition pour discuter en francais de
tout sujet technique lie a XML.
Pour resilier votre abonnement, envoyez un message contenant
la commande "unsubscribe" a xml-tech-request@xmlfr.org
(mailto:xml-tech-request@xmlfr.org?Subject=unsubscribe)
Archive générée par hypermail 2.1.3 le 28/06/2004 - 11:06 UTC
webmaster@xmlfr.org
|