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

How to compare two (possibly dissimilar) XML's (XSLT1.

Subject: How to compare two (possibly dissimilar) XML's (XSLT1.0)
From: Mark Anderson <mark@xxxxxxxxxxxxxxxxxxxxxxxx>
Date: Fri, 20 Jan 2012 18:57:36 +0000
 How to compare two (possibly dissimilar) XML's (XSLT1.
Hi Guys

I have an XML comparison XSL that works well for identical XML's; however, I
need to create a version that will compare two slightly dissimilar XML's
(whose structure I do not know--other than root element's name).

One will always be a superset of the other (if different).

For example

A contains

<elements>
    <element1>
        <element1a>1a</element1a>
        <element1b>1b</element1b>
        <element1c>1c</element1c>
    </element1>
    <element2>
        <element2a>2a</element2a>
        <element2b>2b</element2b>
        <element2c>2c</element2c>
    </element2>
    <element3>
        <element3a>3a</element3a>
        <element3b>3b</element3b>
        <element3c>3c</element3c>
    </element3>
</elements>


B Contains

<elements>
    <element1>
        <element1a>1a</element1a>
        <element1b>1b</element1b>
        <element1c>1c</element1c>
    </element1>
    <element3>
        <element3a>4a</element3a>
        <element3c>4c</element3c>
    </element3>
</elements>

I want to iterate through every element and attribute in A, find the
corresponding element in B (if it exists) and compare their values.

For example, the output needs to indicate the following:

element2 is missing
element2/element2a is missing
element2/element2b is missing
element2/element2c is missing
element3/element3b is missing
element3a's value is different
element3b's value is different

Any help greatly appreciated

Regards

Mark

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.