Re: [xsl] How to sort attribute?

Subject: Re: [xsl] How to sort attribute?
From: Tony Lavinio <xml1@xxxxxxxxxxx>
Date: Mon, 15 Aug 2005 01:20:13 -0400
On 08-14-2005 10:22 PM, John Li wrote:

I implement a parser of one XML related spec. In it, it defines the  format
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 elements
are sorted lexicographically with respect to the element names and attribute

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

If you want canonical XML, there is more to it than just having the attributes sorted in order by name. There are whitespace issues, the encoding must be in UTF-8, there can be no <?xml?> prolog at the beginning, etc.

That particular aspect is handled by the serializer; no amount
of XSLT coding will guarantee that attributes come out in any
given order.

Why exactly must they be in that order?  What "big trouble" will
it cause?

If you are depending on the order of attributes to be alphabetical,
then you are not writing an XML parser.  You're writing a parser
that accepts some *subset* of well-formed XML documents, which is
a different beast.

Tony Lavinio
Stylus Studio Principal Software Architect

Current Thread