[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|