RE: [xsl] How to verify equivalence of two node trees ?

Subject: RE: [xsl] How to verify equivalence of two node trees ?
From: "Michael Kay" <mike@xxxxxxxxxxxx>
Date: Thu, 28 Oct 2004 08:02:56 +0100
You need to provide much more detailed specifications of your three equality
functions - you might like to look at the spec of deep-equals() in XPath 2.0
to see the kind of things you need to take into account (or decide not to
take into account). For example, does it matter to you whether the elements
have the same in-scope namespaces? Are whitespace-only text nodes
significant? Are comments and processing instructions significant?

It's a bit easier to write such functions in 2.0, but the essential
technique is the same as at 1.0: you will need a recursive function/template
that walks down the tree applying the same kind of test at each level.

Michael Kay 

> -----Original Message-----
> From: Matt Adams [mailto:mattad@xxxxxxxxx] 
> Sent: 28 October 2004 06:36
> To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
> Subject: [xsl] How to verify equivalence of two node trees ?
> 
> Assume we have two node trees with the root nodes $aroot and $broot:
> 
> <xsl:variable name="aroot" select="...." />
> <xsl:variable name="broot" select="...." />
> 
> How can I test the equivalence of the two node trees ?
> More precisely there are should be three kinds of tests:
> 
> 1.) Testing if tree a is equal to tree b only looking at the elements
> but ignoring possible existing attributes and their values
> 
> 2.) Testing if tree a is equal to tree b regarding the 
> elements and their
> attributes but ignoring the values of the attributes
> 
> 3.) Finally testing if tree a is equal to tree b regarding elements,
> their attribute (names) and the attribbute values.
> 
> How can I implement such a test in XSLT?
> Is there possibly a smarter solution in XSLT 2.0 ?
> 
> Matt
> -- 
> ___________________________________________________________
> Sign-up for Ads Free at Mail.com
> http://promo.mail.com/adsfreejump.htm

Current Thread