Re: une idee pour cette tranformation XSLT ?
Gregoire Cachet <[email protected]> Sat, 06 Mar 2004 15:36:41 +0100
| Newsgroups | gmane.comp.web.blogv2.devel |
|---|---|
| Message-ID | <[email protected]> |
Gregoire Cachet wrote:
>Quelqu'un a-t-il une idée pour traiter ce dernier point ?
>
>
avec les conseils d'Eric, je suis arrivé à quelque chose de pas trop mal :
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" encoding="UTF-8"/>
<xsl:param name="DEFAULT_LANG" />
<xsl:param name="LANG" />
<xsl:template match="/">
<xsl:apply-templates select="*" />
</xsl:template>
<xsl:template match="@* | *[count(@xml:lang) = 0 or (count(@xml:lang) =
1 and lang($LANG))]">
<xsl:copy>
<xsl:apply-templates select="* | @*[name() != 'xml:lang'] |
text()" />
</xsl:copy>
</xsl:template>
<xsl:template match="*[count(@xml:lang) = 1 and not(lang($LANG))]">
<xsl:variable name="nom" select="name(.)" />
<xsl:if test="count(../*[name(.) = $nom and lang($LANG)]) = 0 and
lang($DEFAULT_LANG)">
<xsl:copy>
<xsl:apply-templates select="* | @*[name() !=
'xml:lang'] | text()" />
</xsl:copy>
</xsl:if>
</xsl:template>
</xsl:stylesheet>
Il faudra peut etre retoucher un peu, mais en tout cas, ca marche au
poil ;-)
--
Grégoire Cachet - Développeur intégrateur chez Audacy
http://www.zwiffer.org http://www.audacy.fr
Mangeur de cigogne http://mangeur-de-cigogne.info/