Q:

XSLT to call secondary XML based on first XML element/attribute

love the stuff - newbie Æthelred here
I have a XSLT 1.0 file pulling in a secondary XML (to a variable) to build a table
    <xsl:variable name="table_values" select="document('./table_variants/external_table.xml')/xml/channel_1"/>
I then get the values i need from the variable, eg:
    <xsl:value-of select="$table_values/monkey/tennis/@medals"/>
<xsl:value-of select="$table_values/monkey/tennis/@bananas"/>
What i want to do is have the first XML trigger/steer where to look for the table data.
I hoped i could, within the triggered XML, state the last part of the xpath - the 'channel_1' or 'channel_2', 
    <xsl:value-of select="xml/external_table_channel_to_use"/>
but apparently i cannot create a xpath on the fly like that
Please - What can i do?

A:

What i want to do is have the first XML trigger/steer where to look
  for the table data. I hoped i could, within the triggered XML, state
  the last part of the xpath - the 'channel_1' or 'channel_2',
  <xsl:value-of select="xml/external_table_channel_to_use"/> but
  apparently i cannot create a xpath on the fly like that
Please - What can i do?

This can easily be done just extending the code that you already have.
Change this:
<xsl:variable name="table_values" select=
"document('./table_variants/external_table.xml')/xml/channel_1"/>

to this:
    <xsl:variable name="table_values" select=
        "document('./table_variants/external_table.xml')
                           /xml/*[name() = $channelName"/>

Needless to say, the variable (or global, external param) $channelName should have a value that is the (string) name of the element you want to use in the last location step of the XPath expression.

