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.
-------------------------------------
<catalog>
<cd>
<title>Empire Burlesque(_at_)the nightmare</title>
<artist>Bob Dylan</artist>
<country>USA</country>
<company>Columbia</company>
<price>10.90</price>
<year>1985</year>
</cd>
<cd>
<title>Hide your heart</title>
<artist>Bonnie Tyler</artist>
<country>UK</country>
<company>CBS Records</company>
<price>9.90</price>
<year>1988</year>
</cd>
</catalog>
--------------------------------------
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.
--------------------------------------
<configuration>
<column>title</column>
<column>artist</column>
</configuration>
--------------------------------------
The XSLT would be something like:
--------------------------------------
<?xml version="1.0"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<html>
<body>
<h2>My CD Collection</h2>
<table border="1">
<xsl:for-each select="catalog/cd">
<tr>
<td><xsl:value-of select="title"/></td>
<td><xsl:value-of select="artist"/></td>
</tr>
</xsl:for-each>
</table>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
--------------------------------------
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
--~------------------------------------------------------------------
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>
--~--