[xsl] Specifying an element from a separate XML file

Subject: [xsl] Specifying an element from a separate XML file
From: Roy Stafford <sugarpines@xxxxxxxxx>
Date: Wed, 20 May 2009 15:54:59 -0700
Is it possible to specify an element in one input XML file from a
value in a second configuration XML file using XSLT?

For example I have an "input.xml" file with the desired data.
    <title>Empire Burlesque@the nightmare</title>
    <artist>Bob Dylan</artist>
    <title>Hide your heart</title>
    <artist>Bonnie Tyler</artist>
    <company>CBS Records</company>

And a "configuration.xml" file that states which elements I require.
In this case I wish to output only the title and artist elements and
ignore the country, company and other elements.

The XSLT would be something like:
<?xml version="1.0"?>

<xsl:stylesheet version="1.0"

<xsl:template match="/">
    <h2>My CD Collection</h2>
    <table border="1">
      <xsl:for-each select="catalog/cd">
          <td><xsl:value-of select="title"/></td>
          <td><xsl:value-of select="artist"/></td>


EXCEPT that the <xsl:value-of select="title"/> and <xsl:value-of
select="artist"/> entries would be replaced by the value of each
configuration/column element in configuration.xml file.

My goal is to provide an external configuration file for the
transformation so that the XSLT can be reused without editing.

I'm using Saxon-B 9.1

Current Thread