xsl-list
[Top] [All Lists]

Re: How to sort attribute?

2005-08-14 22:20:13
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
values."

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.

--
Sincerely,
Tony Lavinio
Stylus Studio Principal Software Architect
http://www.stylusstudio.com/
        

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>