1. | xsl:attribute problem with xml:space |
No, this isn't a bug. Because the whitespace after the <xsl:attribute name="a"> element is significant (by virtue of xml:space), it is copied to the result tree as a text node which will form part of the content of the <foo> element. You can't write another attribute ("b") after you have written a child text node to the containing element. With the default error recovery action, Saxon reports the error and then recovers from it by ignoring the <xsl:attribute> instruction. | |
2. | xml:space makes xsl:attribute fail |
It's normaly a bad idea to preserve space in the stylesheet. If you do....
You can't add an attribute after you have added any text to the element body. Normally that newline and space after the <a> would have been stripped and so <xsl:attribute would work but if you preserve that space then it is added as a text node to the output, so you can't add an attribute. David N Bertoni expands on this :-) With xml:space="preserve" in the stylesheet, the literal result element now has a text child. Since that text child is generated before the xsl:attribute instruction is instantiated, the processor cannot add the attribute. See: xslt rec Although the processor is free to halt the transformation at this point, MSXSL is recovering by not adding the attribute. So, you can move the href attribute into the literal result element: <a href="{@start}"> <xsl:value-of select="title"/> </a> or reset xml:space to the default: <a xml:space="default"> <xsl:attribute name="href"> <xsl:value-of select="@start"/> </xsl:attribute> <xsl:value-of select="title"/> </a> I'm surprised you didn't get a warning from the processor. |