Re: [xsl] Matching or testing dynamically created attributes

Subject: Re: [xsl] Matching or testing dynamically created attributes
From: David Carlisle <davidc@xxxxxxxxx>
Date: Thu, 21 Jun 2001 18:22:13 +0100
Short version: While in a for-each loop, how can I match the current node's
attribute (say @NAME) against an attribute in another node somewhere else
without knowing that attribute's name?



 Essentially, "if the @NAME attribute
of this node is the same as an attribute in the node over there, do
something..." 


<xsl:for-each select="xxx">
  <xsl:if test="@NAME=../../x/y//z/@*"/>

will test the value of the current NAME attribute against the node set
of all attributes selected and be true if any of them matches.

If you want to know which ones match, do instead

<xsl:for-each select="xxx">
  <xsl:for-each (or copy-of or variable or apply-templates)
   select="../../x/y//z/@*[.=current()/@NAME]">


or, this NAME is "row1". if there is an attribute in the node
over there named "row1" what is its value?


<xsl:for-each select="xxx">
  <xsl:value-of
   select="../../x/y//z/@*[name(.)=current()/@NAME]"/>

David

_____________________________________________________________________
This message has been checked for all known viruses by Star Internet
delivered through the MessageLabs Virus Scanning Service. For further
information visit http://www.star.net.uk/stats.asp or alternatively call
Star Internet for details on the Virus Scanning Service.

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


Current Thread