RE: Using id() when id and idref are in 2 different fi
> So I have tried using document() to read the castlist into a > variable called $cast. Now I can use <xsl:value-of > select="$cast//@id" /> to output the required values but I > can't get it to work with the id()function. <xsl:value-of > select="id(@who)" /> just fails, which doesn't surprise me. > However <xsl:value-of select="$cast//role[@id = @who]" /> > also returns nothing. Is it because it is now looking for > @who within $cast? Using the id() function relies on the XML getting validated against a DTD (that specifies that attribute as type ID) - are you sure your imported files are being validated? Even then I'm not sure it's possible... As an alternative to the id() function, you could use a key: <xsl:key name="ids" match="*" use="@id"/> and then access the values: <xsl:value-of select="key('ids', @who)"/> Remember to change the context nodes to the referenced XML when you want to key into that: <xsl:variable name="who" select="@who"/> <xsl:for-each select="$cast"> <xsl:value-of select="key('ids',$who)"/> </xsl:for-each> In XSLT 2.0 this can be shortened to: <xsl:value-of select="key('ids', @who, $cast)"/> ...which is great because you don't need the variable anymore. cheers andrew
PURCHASE STYLUS STUDIO ONLINE TODAY!
Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!
Download The World's Best XML IDE!
Accelerate XML development with our award-winning XML IDE - Download a free trial today!
Subscribe in XML format