[xsl] Re:[xsl] disappearing line breaks within an element

Subject: [xsl] Re:[xsl] disappearing line breaks within an element
From: "cavecatem@xxxxxxxxxxxxx" <cavecatem@xxxxxxxxxxxxx>
Date: Tue, 27 Jan 2009 16:59:38
Hi Michael,

thanks for your suggestions.
I had to do some checking up, as I couldn't reproduce your results with my
xslt.

Today I ran some tests with a simple file and a new XSL stylesheet. And things
turn out to be even more confusing that I though:
This is my input file:
<?xml version="1.0" encoding="UTF-8"?>

<test>a&#xD;b&#xD;C&#xD;D</test>

With this stylesheet
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
version="2.0">

    <xsl:output name="inhalt" method="xml"  omit-xml-declaration="yes" />

      <xsl:preserve-space elements="*"/>

    <xsl:template match="test">

        <xsl:copy-of select="."/>

    </xsl:template>
</xsl:stylesheet>

I get
<?xml version="1.0" encoding="UTF-8"?>
<test>a&#xD;b&#xD;C&#xD;D</test>

If the template is
<xsl:template match="test">
        <html>

        <xsl:copy-of select="."/>

        </html>
    </xsl:template>

the result is this:
<html>
   <test>abCD</test>
</html>

As I'm using Oxygen, I checked if the results were the same if I called saxxon
from the command line, and they are.

I do hope the #xd codes are not converted into line breaks when I send this
mail. So, probably to prevent problems with browsers, the line-break codes are
eliminated whenever I output to a descendent of an  html-element.

Regards
CJ

Current Thread