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

Comparing two xml documents

Subject: Comparing two xml documents
From: "Ragulf Pickaxe" <jawxml@xxxxxxxxxxx>
Date: Wed, 12 Mar 2003 15:48:33 +0000
compare two documents
Hello all,

I have two flat xml documents, that I want to compare - let's call them A and B.
I know only the root element of the two documents, all other elements are unknown to me. Only thing is that there are no attributes in the two documents - the elements might be empty or they might not - and that the elements in a given document are unique in name.


The comparisson is both between the contents between two elements of the same name, and finding the elements that are only in one of the documents.

Is there any way to achieve this?

I would imagine matching all elements in A, for each match looking for the element in B. If match is found, then comparing the value, if no match is found then marking this. Then I would go to B and look through all these elements, marking all elements that are not in A.

The problem is, I don't know how to do this, using XSL.

I have a scetch here, with comments on all my problems. Any help would be greatly appreciated:

<!-- Doing the transformation on A -->
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:variable name="B" select="document('B.xml')"/>


 <xsl:template match="/">
   <xsl:apply-templates select="RootElement">
 </xsl:template>

 <xsl:template match="RootElement">
   <xsl:apply-templates/>
 </xsl:template>

<xsl:template match="*"> <!-- Does this match all elements? -->
<!-- Here I would like to be able to search for the element with the same name as the chosen one -->



<xsl:apply-templates select="$B/RootElement"/> <!-- Would this select the RootElement of B? -->
</xsl:template>


 <xsl:template match="$B/RootElement">
   <xsl:apply-templates/>
 </xsl:template>

<xsl:template match="$B/*"> <!-- Does this match the given elements in document B? -->
<!-- And here I want to check whether the element exists in document A. Will I need a variable for that document? And how would I do that, if needed? -->
</xsl:template>



</xsl:transform>



I hope it is possible to do something like this.


Thanks!

Ragulf Pickaxe :)

_________________________________________________________________
Add photos to your messages with MSN 8. Get 2 months FREE*. http://join.msn.com/?page=features/featuredemail



XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list



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.