Re: [xsl] copy-of converts hex to decimal

Subject: Re: [xsl] copy-of converts hex to decimal
From: Martin Honnen <Martin.Honnen@xxxxxx>
Date: Thu, 08 Oct 2009 11:55:26 +0200
Matthias M|ller wrote:

can someone explain why xsl:copy-of converts hex values to decimal?
e.g. the node:


is processed to:


using this template:

<xsl:template match="HexDecTest">
        <xsl:element name="Result">
            <xsl:copy-of select="Hex"/>
            <xsl:copy-of select="Dez"/>

i expected the hex value unchanged,

XSLT works on the XSLT/XPath data model, a tree model. In that model the Hex and the Dez elements have a text node with character data of Unicode characters as a child. The input tree is transformed to a result tree, again with text nodes of Unicode characters.

That result tree can then be serialized and only then you might get characters escaped, for instance when you have specified an output encoding in which the characters can not be directly represented. Your serializer has choosen decimal numbers for escaping.

So the main point is that XSLT does not operate on the markup representation of the input and xsl:copy-of certainly is not a way to copy the markup in the input literally to the output. XSLT operates on a tree often created by parsing an XML document and then creates a result tree and optionally serializes that result tree, often as XML.


	Martin Honnen

Current Thread