[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Specifying an element from a separate XML file

Subject: Specifying an element from a separate XML file
From: Roy Stafford <sugarpines@xxxxxxxxx>
Date: Wed, 20 May 2009 15:54:59 -0700
 Specifying an element from a separate XML file
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


Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
First Name
Last Name
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.