Re: [xsl] XSLT 1.0 serializer for XML

Subject: Re: [xsl] XSLT 1.0 serializer for XML
From: Hermann Stamm-Wilbrandt <STAMMW@xxxxxxxxxx>
Date: Thu, 19 Aug 2010 18:38:24 +0200
| why do  you say > must not be escaped? it is safer to escape it 9and

I just read the spec and '>' is not a must-escape character.
I agree with you that it is better to escape it and I did it in
LtGtAmp template (xml-to-string does not escape '>').


> 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.

Thanks you for that hint. I modified serialize-demo.xsl to add the
attribute and now the generated output starts this way:

<html xml:space="preserve"><body>
<h2>XSLT 1.0 serializer for XML</h2>
...

But the display in IE8 is as ugly as before ...

Or do I have to add xml:space="preserve" to the <pre> tag at the
beginning of the serialized output in serialize-demo.xsl?


Mit besten Gruessen / Best wishes,

Hermann Stamm-Wilbrandt
Developer, XML Compiler, L3
WebSphere DataPower SOA Appliances
----------------------------------------------------------------------
IBM Deutschland Research & Development GmbH
Vorsitzender des Aufsichtsrats: Martin Jetter
Geschaeftsfuehrung: Dirk Wittkopp
Sitz der Gesellschaft: Boeblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294



From:       David Carlisle <davidc@xxxxxxxxx>
To:         xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Cc:         Hermann Stamm-Wilbrandt/Germany/IBM@IBMDE
Date:       08/19/2010 06:02 PM
Subject:    Re: [xsl] XSLT 1.0 serializer for XML



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