RE: [xsl] How to sort attribute?

Subject: RE: [xsl] How to sort attribute?
From: "Ross, Douglas" <DRoss@xxxxxxxxxx>
Date: Mon, 15 Aug 2005 00:07:03 -0400

Just to be clear: Do you want to know how to construct a result document
with the attributes of an element sorted within the element by name? Or
are you asking how do you perform a lexigraphic sort using the names of
an element's attributes?

If the order of the attributes in the result document are significant
then you may have to construct your result document as text output which
makes your xslt code rather yucky.

Like Michael, I wonder why the order of the attributes are so important?
Presuming the consumer needs to access this xml programmatically, it
seems to me, the attributes have to be parsed in order to be accessed,
in which case, the parser could order the attributes in any order it

Douglas Ross
Senior Software Engineer, Advanced Development
Improving the Performance of People and Business(tm) by making software
Smaller, Faster, Sharper, Easier

-----Original Message-----
From: John Li [mailto:johnli121@xxxxxxx]
Sent: Sunday, August 14, 2005 10:23 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] How to sort attribute?

Hi Michael,

I implement a parser of one XML related spec. In it, it defines the
of output file clearly.

"... ... is canonical in the sense that within each child element of the
root, the attributes are sorted lexicographically, and then those
are sorted lexicographically with respect to the element names and

If xerces or xalan cannot do it, that will be a big trouble for me.


-----Original Message-----
Behalf Of Michael Kay
Sent: Monday, August 15, 2005 5:14 AM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: RE: [xsl] How to sort attribute?

> I cannot accept to transform attribute to element. What I want is sort

> the attribute lexicographic.

It would be interesting to know *why* you want to do this.

Is it just for the comfort and convenience of the human reader (an
acceptable reason, though I fear you will be disappointed), or is it
you are sending the XML to a software application that requires the
attributes to be in a particular order (an unacceptable reason)?

Michael Kay

Current Thread