xsl-list
[Top] [All Lists]

RE: [xsl] xsl:for-each and xml:space with text-nodes inbetween

2006-05-08 10:56:59
 

-----Original Message-----
From: Michael Kay [mailto:mike(_at_)saxonica(_dot_)com] 
Sent: Monday, May 08, 2006 7:21 PM
To: xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com
Subject: RE: [xsl] xsl:for-each and xml:space with text-nodes 
inbetween

Some additional tests revealed that some other processors are 
also buggy here. This produces a bit of headache on my side, 
since I would like to be compatible with Saxon and Xalan-J, 
but it seems like the behaviour of those processors does 
deviate from the spec.

Actually, in the case of Saxon, it's not a bug: it was a 
conscious decision
to treat this as an oversight in the spec. I disallowed it at 
one stage, and
got a stream of bug reports, and decided that no useful 
purpose was served
by rejecting these stylesheets. You might disagree with the 
decision, but
the code is doing what it was designed to do.

Now that we are trying to untangle such whitespace issues in
Libxslt, we are hitting similar problems. In this particular
case, I think we'll just keep Libxslt behaviour, which was
to raise an error. For some other issues we'll probably
keep the current behaviour as well and provide a way of specifying
a "strict" stylesheet validation if wanted.

A supplement to the test: Saxon 6.5.3 seems to allow any
"template" content before xsl:sort, i.e., literal result elements,
instructions, etc., while Xalan-J allows only text (regardless if
whitespace-only or not), while MSXML .NET allows only
whitespace-only text.
So we'll happily add Libxslt's behaviour to this hot spot.

The following
<xsl:template match="/">
 <foo>
   <xsl:for-each select="/foo/bar"></bar>--<xsl:sort/><xsl:value-of
select="."/></xsl:for-each>
 </foo>
</xsl:template>

produces with Saxon 6.5.3:

<foo><bar/>--a<bar/>--b<bar/>--c</foo>

The following
<foo>
  <xsl:for-each select="/foo/bar">--<xsl:sort/><xsl:value-of
select="."/></xsl:for-each>
</foo>

produces with Xerces-J:

<foo>--a--b--c</foo>


Regards & thanks for the info,

Kasimier

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--