[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
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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|