There are at least three approaches, the first is to use something like:
Code:
<xsl:for-each select="database/tools/tool">
<tr>
<td>
<xsl:value-of select="toolname"/>
</td>
<td>
<xsl:value-of select="borrower/@bid"/>
</td>
<td>
<xsl:value-of select="/*/customers/customer[@cid = current()/borrower/@bid]/name"/>
</td>
</tr>
</xsl:for-each>
The current() function refers to the context node before the XPath expression is evaluated, alternatively you could store the value in a variable.
The better way to do this is to declare a key to access the customers.
Code:
<xsl:key name="customerById" match="customer" use="@cid"/>
This needs to be outside of any xsl:template element.
You can then use this to retrieve customers:
Code:
<xsl:for-each select="database/tools/tool">
<tr>
<td>
<xsl:value-of select="toolname"/>
</td>
<td>
<xsl:value-of select="borrower/@bid"/>
</td>
<td>
<xsl:value-of select="key('customerById', borrower/@bid)/name"/>
</td>
</tr>
</xsl:for-each>
Thirdly, as you have defined @cid to be of type ID then you can use the id function:
Code:
<xsl:for-each select="database/tools/tool">
<tr>
<td>
<xsl:value-of select="toolname"/>
</td>
<td>
<xsl:value-of select="borrower/@bid"/>
</td>
<td>
<xsl:value-of select="id(borrower/@bid)/name"/>
</td>
</tr>
</xsl:for-each>
--
Joe (
Microsoft MVP - XML)