[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

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


Subject: RE: [xsl] xsl:for-each and xml:space with text-nodes inbetween
From: "Buchcik, Kasimier" <k.buchcik@xxxxxxxxxxxx>
Date: Mon, 8 May 2006 18:46:12 +0200

Hi,

> -----Original Message-----
> From: Buchcik, Kasimier [mailto:k.buchcik@xxxxxxxxxxxx]
>
> > -----Urspr|ngliche Nachricht-----
> > Von: G. Ken Holman [mailto:gkholman@xxxxxxxxxxxxxxxxxxxx]
> > Gesendet: Dienstag, 25. April 2006 22:44
> > An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> > Betreff: Re: [xsl] xsl:for-each and xml:space with text-nodes
> > inbetween
>
> [...]
>
> > >Should any text-node, regardless if it's whitespace-only or not,
> > >be reported as invalid at such a position?
> >
> > Yes, it is an error, and Saxon reports it as an error, because the
> > xml:space="preserve" creates a node of the template before the
> > xsl:sort instruction, which is not allowed.
> >
> > >Using the MSXML .NET Processor, I get the following result:
> > >
> > ><?xml version='1.0' encoding='utf-8' ?>
> > ><foo> a b c</foo>
> >
> > I would assess that as a bug ... the space character is
> clearly part
> > of the template and the standard does not allow any part of the
> > template before xsl:sort.
> >
> > >then an error is reported concerning the invalid position
> of xsl:sort
> > >inside xsl:for-each. I'm confused here.
> >
> > I think you are confused because of the bug.
>
> [...]
>
> Ah, this makes sense now.
> Thank you very much for taking time for this case!

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.

I'm currently testing under Stylus Studio HE 6, so I'm not sure
how up-to-date the processors are. I'd be happy if someone could
confirm that this is the actual up-to-date behaviour of those
XSLT 1.0 processors.

Input:

<?xml version="1.0"?>
<foo>
	<bar>b</bar>
	<bar>c</bar>
	<bar>a</bar>
</foo>

Scenario A:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <foo>
      <xsl:for-each select="/foo/bar" xml:space="preserve">i<xsl:sort
/><xsl:value-of select="."/></xsl:for-each>
    </foo>
  </xsl:template>
</xsl:stylesheet>

Output from Saxon 6.5.3 and Xalan-J:

<?xml version='1.0' ?>
<foo>iaibic</foo>

MSXML .NET and Libxslt report an error.

Scenario B:

<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
  <xsl:template match="/">
    <foo>
      <xsl:for-each select="/foo/bar" xml:space="preserve"> <xsl:sort
/><xsl:value-of select="."/></xsl:for-each>
    </foo>
  </xsl:template>
</xsl:stylesheet>

Output from Saxon 6.5.3, Xalan-J and MSXML .NET:

<?xml version='1.0' ?>
<foo> a b c</foo>

Libxslt reports an error (at transformation time).

Regards,

Kasimier


Current Thread
Keywords