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

RE: Testing 2 XML documents for equality - a solution

Subject: RE: Testing 2 XML documents for equality - a solution
From: Mukul Gandhi <mukul_gandhi@xxxxxxxxx>
Date: Wed, 30 Mar 2005 09:10:16 -0800 (PST)
comparing canonical xml
Thanks a lot Mike for your observations.. I propose
this code to solve the attribute ordering problem you
cited (for both the documents).

<xsl:for-each select="$doc1//@*">
  <xsl:sort select="." />

i.e. adding a xsl:sort instruction in the for-each
loop. This shall solve this problem!

At the very start I said my stylesheet is catering
*strictly to XSLT 1.0* ! I am aware that XSLT 2.0
provides many new features which will help in better
ways to solve this problem.
I'll surely look at the deep-equals() spec in XSLT 2.0
, and the Canonical XML definition.. In fact I took a
cursory look at the Canonical XML spec sometime back.
*I feel my stylesheet caters to a large subset of
Canonical XML definition (I guess about 70-90%). Can
you please comment on my this claim? *

Also thanks for your other ideas..

Regards,
Mukul

--- Michael Kay <mike@xxxxxxxxxxxx> wrote:

> First you need to specify what you mean by equality.
> This is a difficult
> question. You could look to the spec of
> deep-equals() in XSLT 2.0 for
> guidance, or to the Canonical XML definition.
> There's scope for endless
> debate concerning issues such as comments,
> whitespace, namespace prefixes,
> unused namespace declarations, and so on.
> 
> Your stylesheet will treat 
> 
> <a x="1" y="2"/>
> 
> and
> 
> <a y="2" x="1"/>
> 
> as being not equal, which is definitely wrong.
> 
> Algorithms based on concatenating the contents of
> both documents and then
> comparing them as strings are likely to have the
> possibility of returning a
> false equality.
> 
> An algorithm that uses recursive descent of both
> trees is likely to be much
> faster in the case where the trees aren't equal. 
> 
> Michael Kay
> http://www.saxonica.com/




		
__________________________________ 
Do you Yahoo!? 
Yahoo! Small Business - Try our new resources site!
http://smallbusiness.yahoo.com/resources/ 

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.