[Home] [By Thread] [By Date] [Recent Entries]
Martin Honnen schrieb:
Ben Stover wrote:
Do you know what's wrong?
<xsl:stylesheet xml:space="preserve" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xsd="http://www.w3.org/2001/XMLSchema" version="2.0"> <xsl:template match="xsd:annotation"/> <xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template></xsl:stylesheet> The xml:space on the xsl:stylesheet is a very bad idea. It leads to every single whitespace-only text node being relevant, which makes the stylesheet create whitespace-only text nodes after the <xsl:template> and after <xsl:copy> (and elsewhere). So child nodes are created *before* applying templates to attributes. Creating attributes after having created child nodes is not allowed. Just to illustrate the principle here, the following will work (but it's a very odd arrangement, avoid that): <xsl:template match="@* | node()"><xsl:copy><xsl:apply-templates select="@* | node()"/> </xsl:copy> </xsl:template> Just get rid of the xml:space="preserve" - it's the source of your problems. Sometimes you'll want whitespace-only text nodes in your source tree (XSLT stylesheet module) to be kept and copied, but then you'll probably also want to localize the effect of the xml:space you insert to achieve that effect. -- Michael Ludwig
|

Cart



