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[(_at_)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
--~------------------------------------------------------------------
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--