[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: xsl:for-each and xml:space with text-nodes inbetwe

Subject: RE: 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
xsl template xml space
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: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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2011 All Rights Reserved.