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

RE: How to compare the attributes of two elements to e

Subject: RE: How to compare the attributes of two elements to ensure that they are equal
From: "Michael Kay" <mhk@xxxxxxxxx>
Date: Wed, 29 Oct 2003 07:42:40 -0000
xpath compare attributes
The XPath 2.0 functions and operators spec includes an algorithm to do
this as part of the definition of the deep-equal() function, and it's
fairly tortuous even using XPath 2.0 constructs. I would tackle it as a
grouping problem: take the union of the two sets of attributes, group
them on a compound key consisting of the attribute name and the
attribute value, and then check that each group has size 2.

Michael Kay

> -----Original Message-----
> From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx 
> [mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of 
> Arvind Bassi
> Sent: 29 October 2003 02:10
> To: XSL-List@xxxxxxxxxxxxxxxxxxxxxx
> Subject:  How to compare the attributes of two elements 
> to ensure that they are equal
> 
> 
> What is the best way to compare two elements in terms of 
> their attributes, and the attribute values? I need to ensure 
> that each element has the same number of attributes, the same 
> attribute names and the same attribute values.
> 
> I am currently working on a stylesheet which compares two xml 
> documents, and generates the differences between them. I have 
> used Lar Huttar's xml document comparison stylesheet as my 
> base (located at http://www.dpawson.co.uk), but am stuck on 
> augmenting it with checks on attributes.
> 
> I am currently stuck with something along the lines of:
> 
>    ...
>        <xsl:call-template name="compare-attributes">
>           with nodes as parameters
>    ...
>    <xsl:template name="compare-attributes">
>         <xsl:param name="attrA"/>
>         <xsl:param name="attrB"/>
>         <xsl:for-each select="$attrA/@*">
>                .... check that the same attribute exists with
>                .... the same attribute exists 
>                if it does then compare the values for equality
> 
>         </xsl:for-each>
>     </xsl:template>
> 
> However, l cannot get a handle on each of the two attributes 
> to compare them. Can somebody help to fill in the blanks?
> 
> Thanks.
> 
> Arvind.
> 
> ______________________________________________________________
> __________
> Want to chat instantly with your online friends?  Get the 
> FREE Yahoo! Messenger http://mail.messenger.yahoo.co.uk
> 
>  XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
> 


 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.