Re: [xsl] XSLT 1.0 serializer for XML

Subject: Re: [xsl] XSLT 1.0 serializer for XML
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 19 Aug 2010 17:01:35 +0100
On 19/08/2010 15:26, Hermann Stamm-Wilbrandt wrote:

Question 1: While '<' and'&' must be escaped,'>' must not. But the output of <xsl:copy-of select="/"/> does escape the '>', too.

why do you say > must not be escaped? it is safer to escape it 9and it looks more symmetric with , if you do) as if you do not escape every occurence of > in text you have to check for the string ]]> and escape at least one of those characters. But if you leave the escaping of > to the xslt serialiser it will presumably get this right, either escape them all or just when needed.


This was the reason for template escapeLtGtAmp to escape all three in
order to match the copy-of behavior.
Why does xsl:copy-of escape '>'?

copy-of doesn't escape anything. In teh result tree formed by xslt the character isn't esacaped. Then when the result tree is serialised it may or may not be escaped at the choice of the XSLT system (but this choice will be for all < without any knowledge of whether it came from copy-of.




Question 2:
The displayed output looks quite nice for Firefox, Chrome, Safari and Opera
browsers (Firefox does not support the namespace:: axis and cannot handle
and display namespaces).
Why is the serialized XML displayed by IE6 and IE8 looking completely
different to all the other browsers (ugly)?

Most likely the well known non-conformance of msxml which discards all white space text nodes. Stick xml:space="preserve" at the top level of your output document to avoid this. (generate it with <xsl:attribute name="xml:space", don't put a literal xml:space attribute in your stylesheet.




Question 3:
Is it correct, that a stylesheet cannot have access to the CDATA sections?
(I think the parser removes them)

true


Question 4:
Is it correct, that a stylesheet cannot access the "original" attribute
values (including eg. newlines) but only the result of Attribute-Value
Normalization [8]?

yes



David


________________________________________________________________________
The Numerical Algorithms Group Ltd is a company registered in England
and Wales with company number 1249803. The registered office is:
Wilkinson House, Jordan Hill Road, Oxford OX2 8DR, United Kingdom.

This e-mail has been scanned for all viruses by Star. The service is
powered by MessageLabs. ________________________________________________________________________


Current Thread