xsl-list
[Top] [All Lists]

RE: xml:preserve space makes xsl:attribute fail in IE6

2002-12-12 03:10:07
For my xsl stylesheet, using

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"; 
version="1.0" xml:space="preserve"> in IE6, I had a problem.

I found that when using the xsl:attribute construct like this, no 
attributes were added to my anchor tag (by checking the HTML source)

         <a>
         <xsl:attribute name="href">
                 <xsl:value-of select="@start"/>
         </xsl:attribute>
         <xsl:value-of select="title"/>
         </a>


Because you have said that whitespace is significant, the spaces between
the <a> and the <xsl:attribute> are treated as a text node to be added
as a child of the <a> element in the result tree. It's an error to try
to add an attribute to an element after adding a text node.
Implementations are allowed to either report the error, or ignore the
offending attribute node. It seems MSXML is doing the latter.

Using xml:space="preserve" in a stylesheet is not something I recommend,
unless the relevant section of the stylesheet is pure data that you want
to copy to the result tree.

Michael Kay
Software AG
home: Michael(_dot_)H(_dot_)Kay(_at_)ntlworld(_dot_)com
work: Michael(_dot_)Kay(_at_)softwareag(_dot_)com  
 
I used the space="preserve" to keep my HTML tidy and 
readable. Finally 
after trying a number of otherwise working examples, I removed 
space="preserve" from the stylesheet tag and presto, the 
attribute was 
added as expected.

I am transforming the XML source in javascript, setting up an 
XML object 
with MSXML2.DOMDocument ...

Questions : is there a known problem with preserve space on IE6 ?

Would this occur if I were to transform the XML server side (is it a 
javascript problem) ?

Is there any other way to keep the HTML output formatting as 
indented in 
the stylesheet ?

Thanks for any feedback.
Regards,
Neil Smith.






 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list



 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list