XML:
<root>
<events>
<event id="e1" v_id="v1">
<elements></elements>
</event>
<event id="e1" v_id="v2">
<elements></elements>
</event>
<event id="e1" v_id="v2">
<elements></elements>
</event>
</events>
<venues>
<venue venue_id="v1">
<venue_name></venue_name>
<elements></elements>
</venue>
<venue venue_id="v2">
<venue_name></venue_name>
<elements></elements>
</venue>
</root>
XSLT:
<xsl:template match="/">
<xsl:apply-templates select="/root/events/event"/>
</xsl:template>
<xsl:template match="event">
<xsl:value-of select="/root/venues/venue[@venue_id = /root/events/event/@v_id]/venue_name"/>
<xsl:text>This is where I would like to put the venue name as a link to that venue</xsl:text>
</xsl:template>
so if the v_id = v2 and the venue_id = v2 I want to display the value of venue_name from the venue with id = v2
Thanks
This is exactly the kind of issue that keys are designed to deal with.
In the root of your stylesheet, add
This effectively declares an associative array of all
venueelements, indexed on theirvenue_idattribute. With this, you can get thevenueelement with any givenvenue_idattribute using thekeyfunction. I believe you can achieve what you need by substituting your<xsl:text>line with this:This essentially looks up the right
venueelement, and gets thevenue_namechild within it.