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
| <?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" version="1.0" encoding="UTF-8" indent="yes"/>
<xsl:variable name="apos">'</xsl:variable>
<xsl:template match="B">
<!-- Traitement de B nombre décimal qui peut être entier-->
<B>
<xsl:attribute name="Des"><xsl:value-of select="@Des"/></xsl:attribute>
<xsl:choose>
<xsl:when test="contains(node(), '.')">
<xsl:value-of select="translate(format-number(., '###,###.##'), ',', $apos)"/>
</xsl:when>
<xsl:otherwise>
<xsl:number value="node()" grouping-separator="'" format="1" grouping-size="3"/>.-- </xsl:otherwise>
</xsl:choose>
</B>
</xsl:template>
<xsl:template match="N">
<!-- Traitement de N nombre entier-->
<N>
<xsl:attribute name="Des"><xsl:value-of select="@Des"/></xsl:attribute>
<xsl:number value="node()" grouping-separator="'" format="1" grouping-size="3"/></N>
</xsl:template>
<xsl:template match="D">
<!-- Traitement de D date pour passer de yyyy-MM-dd a dd.MM.yyyy-->
<D>
<xsl:attribute name="Des"><xsl:value-of select="@Des"/></xsl:attribute>
<xsl:value-of select="concat(substring(node(), 9, 2), '.', substring(node(), 6, 2), '.', substring(node(),1,4))"/></D>
</xsl:template>
<xsl:template match="*">
<xsl:copy>
<xsl:apply-templates select="*|@*|text()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="@*">
<xsl:attribute name="{name()}"><xsl:value-of select="."/></xsl:attribute>
</xsl:template>
</xsl:stylesheet> |
Partager