Subject: Re: [xsl] Data-driven Display of records with variable number of fields From: Wendell Piez <wapiez@xxxxxxxxxxxxxxxx> Date: Thu, 09 Dec 2004 18:46:46 -0500 |
<xsl:for-each select="$records"> <xsl:variable name="thisrecord" select="."> <xsl:for-each select="/headers/*"> <xsl:apply-templates select="$thisrecord/*[local-name()=local-name(current())]"/> </xsl:for-each> </xsl:for-each>
Cheers, Wendell
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
====================================================================== Wendell Piez mailto:wapiez@xxxxxxxxxxxxxxxx Mulberry Technologies, Inc. http://www.mulberrytech.com 17 West Jefferson Street Direct Phone: 301/315-9635 Suite 207 Phone: 301/315-9631 Rockville, MD 20850 Fax: 301/315-8285 ---------------------------------------------------------------------- Mulberry Technologies: A Consultancy Specializing in SGML and XML ======================================================================
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Data-driven Display of record, Rich Caloggero | Thread | Re: [xsl] Data-driven Display of re, Rich Caloggero |
Re: [xsl] Convert 2 xml with 1 xsl , JBryant | Date | Re: [xsl] Convert 2 xml with 1 xsl , JBryant |
Month |