About xml:space and xsl:space

webmasterbeta

New Member
Hi, I am new to XML. Maybe you guys can help me.

I have two files "whitespaces.xml" and "whitespaces.xsl". Please check the listings of these files at the end of the post.

I use IE6.0 to open my XML file. I'd like the output to be "One Two Three Four" but the current output is "One TwoThree Four" (no space between two and three). I also tried this code with Mozilla and it worked as I wished. However, I need it to work with IE too.

I've done a bit of research and I found that the attribute xml:space was what I've been looking for. Unfortunatly, I didn't get to make it work properly.

When I modify the <p> tag in my XML file to <p xml:space="preserve">, it works great but when I try applying this attribute in my XSL file, IE seems to simply ignore it.

Here's a list of possible solution that didn't work for me:
1) <xsl:template match="p" xsl:space="preserve">
2) <p><xsl:apply-templates xsl:space="preserve"/></p>
3) <!DOCTYPE root [ <!ATTLIST p xml:space (default|preserve) #FIXED "preserve"> ]>

Thank you so much in advance!!!

[whitespaces.xml] listing:
----------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<?xml-stylesheet type="text/xsl" href=http://www.webdeveloper.com/forum/archive/index.php/"whitespaces.xsl"?>

<root>

<p>

One <i>Two</i> <link>Three</link> Four

</p>

</root>

----------------------------------

[whitespaces.xsl] listing:
----------------------------------
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE xsl:stylesheet>

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

<xsl:template match="/">
<html>

<head>
<title>Test page</title>
</head>

<body>

<xsl:apply-templates/>

</body>
</html>
</xsl:template>

<xsl:template match="p">
<p><xsl:apply-templates/></p>
</xsl:template>

</xsl:stylesheet>
----------------------------------
 
Back
Top