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

xsl:sort descending causes attribute nodes to be creat

Subject: xsl:sort descending causes attribute nodes to be created after children, causing an error
From: Abel Braaksma <abel.online@xxxxxxxxx>
Date: Tue, 16 Jan 2007 14:00:48 +0100
 xsl:sort descending causes attribute nodes to be creat
Hi XSLT'ers,

The following issue is easy to workaround, but I am wondering if this is correct behavior after the XSLT 2 (or even 1) recommendation.

With an xsl:apply-template that includes attribute nodes in its select-attribute, and you apply an xsl:sort on the children, then it happens that the attribute nodes are created after the children when the order of xsl:sort is descending. I tried google on this, but couldn't find something useful.

The example below throws the following error:
"An attribute node (count) cannot be created after the children of the containing element"


I did not try other parsers. The xslt employs a simple copy idiom and sorts the rows of the input in $data. Call the XSLT on itself to see the error or the results:

<xsl:stylesheet
   xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
   version="2.0">

<xsl:output indent="yes" />
<xsl:variable name="data">
<rows count="3">
<row>bbbb</row>
<row>aaaa</row>
<row>cccc</row>
</rows>
</xsl:variable>
<xsl:template match="/">
<xsl:apply-templates select="$data/*" />
</xsl:template>
<xsl:template match="node() | @*">
<xsl:copy>
<xsl:apply-templates select="node() | @*" />
</xsl:copy>
</xsl:template>


   <xsl:template match="rows">
       <xsl:copy>
           <xsl:apply-templates select="node() | @*">
               <xsl:sort
                   select="text()"
                   order="descending" />
           </xsl:apply-templates>
       </xsl:copy>
   </xsl:template>

</xsl:stylesheet>


Any thoughts on this? Is this behavior desired and/or required, or is this the processor's mistake?


Btw: a possible workaround is to apply the attribute node first.

Cheers,
-- Abel Braaksma
  http://www.nuntia.nl

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-2013 All Rights Reserved.