J'essaie de comprendre comment préserver les espaces entre les noeuds que je trie. Voici un exemple.Préserver les espaces entre xsl: noeuds sort'd
Entrée:
<a>
<b>
<c>
<d>world</d>
</c>
<c>
<d>hello</d>
</c>
</b>
<e>some other stuff</e>
</a>
sortie souhaitée:
<a>
<b>
<c>
<d>hello</d>
</c>
<c>
<d>world</d>
</c>
</b>
<e>some other stuff</e>
</a>
Voici mon xslt:
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="@*|node()">
<xsl:copy>
<xsl:apply-templates select="@*|node()"/>
</xsl:copy>
</xsl:template>
<xsl:template match="a/b">
<xsl:copy>
<xsl:apply-templates select="c">
<xsl:sort select="d"/>
</xsl:apply-templates>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
Et quand je le lance à travers xsltproc, je reçois ceci:
<a>
<b><c>
<d>hello</d>
</c><c>
<d>world</d>
</c></b>
<e>some other stuff</e>
</a>
Je préfère ne pas le faire passer par la suite après. Des idées?