[XSL-LIST Mailing List Archive Home] [By Thread] [By Date]

[xsl] comparing attributes values dynamically


Subject: [xsl] comparing attributes values dynamically
From: Adam Foran <aforan@xxxxxxxxx>
Date: Mon, 5 Jan 2004 10:30:36 -0500

Hi,

I think I've got hung up a bit on some XSLT syntax
that I'm hoping someone here can help me with. I've
tried to both Google and FAQ reading, but haven't found
anything that's helped.

I'm trying to compare two versions of the 'same' node
(one pulled out of an old version of my xml file using
document()) and want to iterate through and compare all
the values of all the attributes. I'd like to avoid
having to hard-code in any attribute names.

My XSLT code has a template into which I pass the two
nodes in $newNode and $oldNode but I'm getting compilation
errors. I know the following code is wrong but hopefully
it'll be obvious what I'm trying to accomplish with it:

<xsl:for-each select="$newNode/@*">
  <xsl:if test="string(current()) = $oldNode/@{name()}">
                {_______________}   {________________}
                        ^                  ^
                        |                  |
           the value of the current        |
           attribute                       |
                                           |
           the value of the attribute in $oldNode with the
           same name() as current() (ie. the 'same' sttribute
           in $oldNode)

The test expression fails to compile, but I'm having
difficulty figuring out how to use the result of name()
to specify the attribute to use from the $oldNode.

Thanks very much for any help,

Adam

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



Current Thread
Keywords