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

Data-driven Display of records with variable number of

Subject: Data-driven Display of records with variable number of fields
From: "Rich Caloggero" <rjc@xxxxxxx>
Date: Thu, 9 Dec 2004 16:05:37 -0500
caloggero
Is this possible in xslt-1.0?

Given the following input, I want to transform the output such that I get
only the fields of each record which I specify in the headers element. I
want the order to also be the order in which they appear in the headers
element.  So if headers looks like:
<headers>
<year/> <artist/>
</headers>
then I want each record in the output to only contain the year and artist
fields, in that order.

I can't seem to write an xPath expression for this kind of transform because
xPath node tests cannot contain variables. The expression would need to look
something like "/cds/cd/$field", where $field would contain the name of one
of the nodes listen in /headers (see xml below).

Thanx for any suggestions...

-- Rich

Input:
<?xml version="1.0" encoding="ISO-8859-1" ?>
<?xml-stylesheet type="text/xsl" href="transform.xsl"?><cds>
<title>My CD Collection</title>
<headers>
<title/>
<artist/>
<year/>
</headers>

<cd>
<artist>Rich Caloggero</artist>
<title>A Taste of Tranquility</title>
<year>2004</year>
<label>Touch the Sky Music</label>
</cd>

<cd>
<artist>The Grateful Dead</artist>
<title>Europe 72</title>
<year>1972</year>
</cd>
</cds>



-- Rich
"In the end, our society will be defined not only by what we create, but by
what we refuse to destroy."
-John C. Sawbill (1936-2000), president, The Nature Conservancy, 1990-2000

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

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.
Email
First Name
Last Name
Company
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.