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. ------------------------------------- <catalog> <cd> <title>Empire Burlesque@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
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Need XSL coding, List Owner | Thread | Re: [xsl] Specifying an element fro, David Carlisle |
[xsl] Need XSL coding, Selva Ganesh | Date | Re: [xsl] Specifying an element fro, David Carlisle |
Month |