[XSLT] test sur Tagname pour modification
Bonsoir à tous,
J'aimerais faire la transformation suivante :
Un fichier XML contenant dans un bloc:
Code:
1 2 3 4 5 6 7 8 9 10 11 12
|
<DAYS>
<item>
<NUMBER>Day1</NUMBER>
<VALUE>1.000</VALUE>
</item>
...
<item>
<NUMBER>Day31</NUMBER>
<VALUE>0.000</VALUE>
</item>
</DAYS> |
vers :
Code:
1 2 3 4
|
<Day1>1.000</Day1>
...
<Day31>0.000</Day31> |
Cependant, je pêche par ma méconnaissance de XSLT et XPATH.
Voici le code qui ne fonctionne pas vraiment :
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
<xsl:transform xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:sap="http://www.sap.com/sapxsl" version="1.0">
<xsl:strip-space elements="*"/>
<xsl:template match="*">
<xsl:apply-templates mode="copy" select="self::*"/>
</xsl:template>
<xsl:template match="item" priority="1">
<xsl:element name="{NUMBER}">
<xsl:value-of select="VALUE"/>
</xsl:element>
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="DAYS" priority="0">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="NUMBER" priority="0">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="VALUE" priority="0">
<xsl:apply-templates/>
</xsl:template>
<xsl:template match="*" mode="copy">
<xsl:copy>
<xsl:apply-templates/>
</xsl:copy>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of select="."/>
</xsl:template>
</xsl:transform> |
Vous remerciant pour votre aide,
L.