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

RE: Sorting the complete xml file

Subject: RE: Sorting the complete xml file
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Sun, 11 Dec 2005 16:20:36 -0000
xml sort nodes
> What is this serializer? Is the implememtation of the 
> serializer defined by W3C? 

The term "serializer" is not actually used in the XSLT 1.0 specification,
though it is widely used in the XSLT literature, and is defined as a
technical term in the 2.0 specification.

The serializer is the component that converts a tree (typically, the result
tree produced by an XSLT transformation) into lexical XML. That is, it's the
inverse of a parser. The behavior of the serializer is described in section
16 of the XSLT 1.0 specification http://www.w3.org/TR/xslt#output, and in
the 2.0 specs it's in a separate document all on its own:
http://www.w3.org/TR/xslt-xquery-serialization/

> Does it guaranty
> that the order will always be the same, every time it is ran? 

No. In general, it only prescribes the serialized output in terms of
"round-tripping": when you serialize a tree, and then put the resulting
lexical XML through a parser, you get back an "equivalent" tree. The order
of attributes produced by a serializer is therefore not defined (since the
parser is allowed to deliver the results in a different order anyway). 

> My ultimate goal is to compare 2 xml
> files. So it doesn't really matter if I can't sort the attributes.

If you want to compare two lexical XML files, it's best to turn them into
Canonical XML before comparing them. This will iron out differences such as
<a href="x"/> versus <a  href='x'></a>. Alternatively, use a tool such as
DeltaXML which has already addressed these issues.

> 
> From an XML file, what can we sort?(Node name?, Node value?, 
> etc). 

In XSLT, you can sort nodes on any value that is computable using an XPath
expression evaluated with that node as the context node. These certainly
include the name and string value of the node.

My idea is to sort from the
> left side of the tag to the right side, like sorting nodes in 
> a tree level by level until you
> reach the leaf node. 

I'm afraid I don't really understand what you mean by "the left side of a
tag".

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.