Subject: RE: [xsl] xsl:for-each and xml:space with text-nodes inbetween From: "Michael Kay" <mike@xxxxxxxxxxxx> Date: Tue, 25 Apr 2006 21:42:23 +0100 |
XSLT 2.0 spells the rules out in great detail: http://www.w3.org/TR/xslt20/#stylesheet-stripping In 1.0 I think that a strict reading of the spec tells you (a) whitespace text nodes in the stylesheet are not stripped if xml:space="preserve" is specified (section 3.4) (b) Text nodes, however snowy-white they are, are not permitted as children of an element such as xsl:choose, or before the xsl:sort child of xsl:for-each (section 18) This is the interpretation that I adopted in Saxon; but it's somewhat severe, and it's not surprising that some XSLT 1.0 processors have chosen a more liberal approach. We made an explicit decision to adopt the more liberal approach in XSLT 2.0, if only because it's more consistent with the rules for XML validity in the presence of a DTD. Michael Kay http://www.saxonica.com/ > -----Original Message----- > From: Buchcik, Kasimier [mailto:k.buchcik@xxxxxxxxxxxx] > Sent: 25 April 2006 20:46 > To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx > Subject: [xsl] xsl:for-each and xml:space with text-nodes inbetween > > Hi, > > Does someone know what an XSLT 1.0 processor is expected to > do if the immediate child-node of an xsl:for-each is a > whitespace-only text node, which is preserved by xml:space? > Should any text-node, regardless if it's whitespace-only or > not, be reported as invalid at such a position? > > Example > > Stylesheet: > <?xml version='1.0'?> > <xsl:stylesheet version="1.0" > xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> > <xsl:template match="/"> > <foo> > <!-- There's whitespace between xsl:for-each > and xsl:sort. --> > <xsl:for-each select="/foo/bar" > xml:space="preserve"> <xsl:sort /><xsl:value-of > select="."/></xsl:for-each> > </foo> > </xsl:template> > </xsl:stylesheet> > > Input: > <?xml version="1.0"?> > <foo> > <bar>b</bar> > <bar>c</bar> > <bar>a</bar> > </foo> > > Using the MSXML .NET Processor, I get the following result: > > <?xml version='1.0' encoding='utf-8' ?> > <foo> a b c</foo> > > If I change the whitespace-only text-node to contain a letter: > ... > <xsl:for-each select="/foo/bar" > xml:space="preserve">X<xsl:sort /><xsl:value-of > select="."/></xsl:for-each> ... > then an error is reported concerning the invalid position of > xsl:sort inside xsl:for-each. I'm confused here. > > Was this maybe clarified in the XSLT 2.0 spec? > > Regards, > > Kasimier
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] xsl:for-each and xml:space wi, Buchcik, Kasimier | Thread | Re: [xsl] xsl:for-each and xml:spac, G. Ken Holman |
[xsl] xsl:for-each and xml:space wi, Buchcik, Kasimier | Date | Re: [xsl] xsl:for-each and xml:spac, G. Ken Holman |
Month |