Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

XSL:for-each and sibling nodes

Status
Not open for further replies.

lawlerpat

Programmer
Jun 28, 2002
54
US
Hello,
Question: From within a xsl:for-each statement can I use an xsl:if statement to compare a node value from w/in the for-each branch to a node outside the for-each

Example:
<data>
<app>
<record/>
</app>
<tenant>
<handle/>
</tenant>
<data>
Can I have a for-each &quot;data/app&quot; and inside of that obtain the value of a node inside the data/tenant path?

Thanks,
Patrick
 
Yes you can.
Suppose each 'data'-node has only one childnode 'tenant', and your context is 'app', you can refer to the 'tenant'-child of the ancestor.
So:
<xsl:for-each select=&quot;app&quot;>
<xsl:if test=&quot;record=../tenant/handle&quot;>
etc
would do the trick.

In more complicated situations you might use variables to keep a reference to a node that is diffult to get at from your context.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top