Hi Ian,
This achieves what I think you want.
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:key name="product_name" match="product" use="@name"/>
<xsl:template match="/products">
<xsl:call-template name="nucleus_friendly_productname"><xsl:with-param
name="product_name_in" select="'General'"/></xsl:call-template>
</xsl:template>
<xsl:template name="nucleus_friendly_productname">
<xsl:param name="product_name_in"/>
<xsl:value-of
select="key('product_name',$product_name_in)/@friendlyname"/>
</xsl:template>
</xsl:stylesheet>
tested using file product.xml :-
<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" href="get.xsl"?>
<products>
<product name="Maxi-ISA" friendlyname="Isa" />
<product name="PEP" friendlyname="Personal Equity Plan" />
<product name="General" friendlyname="General account" />
<product name="Pension" friendlyname="Pension drawdown" />
</products>
Of course the document context is already that of the product.xml document.
Hope this helps you,
Warrell
"IanK" <ia**************@yahoo.co.ukwrote in message
news:11**********************@n67g2000cwd.googlegr oups.com...
>I have a file called product.xml as follows:
<products>
<product name="Maxi-ISA" friendlyname="Isa" />
<product name="PEP" friendlyname="Personal Equity Plan" />
<product name="General" friendlyname="General account" />
<product name="Pension" friendlyname="Pension drawdown" />
</products>
This is a file that maps product names (the "name" field) onto
user-friendly names (friendlyname) that can be used in client
documentation. I have the following code in my XSL function file that
tries to reference it. It is not working - what am I doing wrong?
<xsl:key name="product_name" match="product" use="@name"/>
<xsl:variable name="products" select="document('product.xml')"/>
<xsl:template name="nucleus_friendly_productname">
<xsl:param name="product_name_in"/>
<xsl:for-each select="document('products.xml')">
<xsl:variable name="product" select="key('product_name',
$product_name_in)"/>
<xsl:value-of select="$product/@friendlyname"/>
</xsl:for-each>
</xsl:template>