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

Subject: AW: [xsl] copy-of converts hex to decimal
From: Matthias Müller <pymote@xxxxxxxx>
Date: Thu, 8 Oct 2009 11:31:11 +0000 (GMT)
thanks, that makes sense. so it's a matter of serialization



-----
UrsprC<ngliche Mail ----
Von: Martin Honnen <Martin.Honnen@xxxxxx>
An:
xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Gesendet: Donnerstag, den 8. Oktober 2009,
11:55:26 Uhr
Betreff: Re: [xsl] copy-of converts hex to decimal

Matthias
MC<ller wrote:

> can someone explain why xsl:copy-of converts hex values to
decimal?
> e.g. the node:
> 
> <HexDecTest>
>     <Hex>&#x2160;</Hex>
>
<Dez>b </Dez>
> </HexDecTest>
> 
> is processed to:
> 
> <Result>
>
<Hex>b </Hex>
>    <Dez>b </Dez>
> </Result>
> 
> using this template:
> 
>
<xsl:template match="HexDecTest">
>         <xsl:element name="Result">
>
<xsl:copy-of select="Hex"/>
>             <xsl:copy-of select="Dez"/>
>
</xsl:element>
> </xsl:template>
> 
> 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
http://msmvps.com/blogs/martin_honnen/

Current Thread