Subject: saving a node in a variable From: Natalie Rooney <nrooney@xxxxxxxxxxxxx> Date: Thu, 11 Nov 1999 13:26:10 -0600 |
Hi, I have the follwing xsl: <xsl:for-each select="//BADUSER"> stuff <xsl:for-each select="//NEWUSER/*"> <xsl:variable name="tagName"><xsl:value-of select="name()"/></xsl:variable> <TR> <TD width="136" bgcolor="#FFCC00"> <xsl:apply-templates select="//DISPLAYNAMES/*[name()=$tagName]"/> </TD> <TD width="376" bgcolor="#99CC33"><xsl:value-of select="."/></TD> <TD bgcolor="#FFCC00"> SCORE FOR BADUSER ATTRIBUTE </TD> <TD width="376" bgcolor="#99CC33"> BADUSER ATTRIBUTE </TD> </TR> </xsl:for-each> </TABLE> </p> </xsl:for-each> This is basically a comparison of two users (a bad one and a new one), each of which have several attributes (the attributes of the bad user have the same names as those of the new one). The attributes are child nodes, such as: <NEWUSER> <FIRSTNAME> </FIRSTNAME> <LASTNAME> </LASTNAME> etc... </NEWUSER> My problem is this: I want to do a side-by-side comparison of attributes. So, in the first two columns I display the attribute names and the values of the new user's attributes. Then in the third column, I want to display the score of the same attribute for the BADUSER. And in the fourth column, I display the value of that attribute for the BADUSER. So, it looks like this: Name of attribute Value of attribute Score of same attribute value of attribute for for the baduser compared BADUSER against the new user First Name: Bob 100% Bob Last Name: Clark 70% Clarkson So, I don't quite know how to fill in the last two columns. If I were only doing this for one baduser, I would use: <xsl:value-of select="//BADUSER[1]/*[name()=$tagName]/@score"/> for the SCORE OF THE BADUSER and <xsl:value-of select="//BADUSER[1]/*[name()=$tagName]"/> for the BADUSER ATTRIBUTE. The filter [name()=$tagName] makes sure it matches the same attribute that was displayed for the new user. But, I want this to be done using an <xsl:foreach select="//BADUSER"/> (there are 3 badusers). Is there any way to assign a node set to a variable, so that I could do something like: <xsl:for-each select="//BADUSER"> <xsl:variable name="badNode" select= [current node]/> stuff <xsl:for-each select="//NEWUSER/*"> <xsl:variable name="tagName"><xsl:value-of select="name()"/></xsl:variable> stuff <TD><xsl:value-of select="$badNode/*[name()=$tagName]/@score"/></TD> <TD><xsl:value-of select="$badNode/*[name()=$tagName]"/></TD> </xsl:for-each> </xsl:for-each> Note that the baduser selections have to be done inside the <xsl:for-each select="//NEWUSER/*"> loop, becuase the attributes have to line up. Any ideas? Could this be done using keys? Help will be greatly appreciated. Thanks, Natalie XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: non-breaking space, Charlotte Allen | Thread | RE: saving a node in a variable, Mike Brown |
non-breaking space, Volkmann, Mark | Date | XT Bug? Re: Wish List: Allow <xsl:, Clark C. Evans |
Month |