This is the mail archive of the xsl-list@mulberrytech.com mailing list .


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: Matching or testing dynamically created attributes



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


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]