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

RE: recursive sorting by element name

Subject: RE: recursive sorting by element name
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 29 Nov 2007 17:46:24 -0000
RE:  recursive sorting by element name
> >I am running into some issues / inconsistencies running this 
> >transformation on command line vs. within java vs. which 
> platform I run 
> >it on.  I'm hoping the list might have some pointers on how 
> to resolve his.

>         <xsl:template match="@*|node()">
>                 <xsl:copy>
>                         <xsl:apply-templates select="@*|node()">
>                                 <xsl:sort select="@typeName"/>
>                                 <xsl:sort select="name(.)"/>
>                                 <xsl:sort />
>                         </xsl:apply-templates>
>                 </xsl:copy>
>         </xsl:template>

This code may have the effect of sorting child elements before attributes
(specifically a child element with no typeName attribute whose name
alphabetically precedes the attribute names). You aren't allowed to create
attributes for an element after creating child elements. In XSLT 1.0 the
processor has the option of ignoring the error by discarding the offending
attributes.

> >When I run this on Ubuntu Linux 7.10 (fully updated) using 
> xsltproc, I 
> >encounter this bug:
> >
> >https://bugs.launchpad.net/ubuntu/+source/libxml2/+bug/147144
> >
> >Namely, it reports the error:
> >
> >runtime error: file SortCollections.xsl line 40 element copy 
> Attribute 
> >nodes must be added before any child nodes to an element.

That doesn't look like a bug to me, it looks like correct behaviour.

> >
> >When I run this on Mac OS X 1.5 (Leopard -- fully updated) using 
> >xsltproc, it does exactly what I want with no problems.

That looks like a bug to me.

> >
> >When I run this script from Java 1.6  (using JAXB) with the 
> code below, 
> >the identity transform does not copy all the attributes over.
> >I end up with missing attributes, and I have no idea why.

Xalan is apparently choosing the option to ignore the error and discard the
attributes.

Michael Kay
http://www.saxonica.com/

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.