Article View: borland.public.csharpbuilder.xml
Article #1XSL not working as expected
From: Marc Scheuner
Date: Fri, 18 Jun 2004 06:22
Date: Fri, 18 Jun 2004 06:22
76 lines
3090 bytes
3090 bytes
Folks,
I'm trying to get something done in XSL and either I'm just missing
some silly thing, or it's not possible to do it.... which is it???
What I'm trying to do is have a XML document that (to some degree)
describes a report - basically, it's a collection of labels and XPath
references of where in the XML document to find the values for those
labels. Seems pretty simple and straightforward, and looks something
like this:
<?xml version="1.0" encoding="ISO-8859-1"?>
<root>
<reportstruct>
<firstpage>
<items>
<item>
<label>Label 1</label>
<ref>/dbdata/basic/item1</ref>
</item>
<item>
<label>Label 2</label>
<ref>//dbdata/basic/item2</ref>
</item>
</items>
</firstpage>
</reportstruct>
<dbdata>
<basic>
<item1>10299</item1>
<item2>1.850.897</item2>
</basic>
</dbdata>
</root>
So what I'd like to see in my final HTML is a table with all the
labels as defined in the "root/reportstruct/items" collection, and
their associated value as specified in the "ref" element for each
<item>.
My XSL for that part looks something like this:
<table width="100%">
<xsl:for-each select="root/reportstruct/firstpage/items/item">
<tr>
<td style="font-weight: bold" width="50%">
<xsl:value-of select="label" />
</td>
<td>
<xsl:variable name="DataRef"
select="ref" />
<xsl:value-of select="{$DataRef}" />
</td>
</tr>
</xsl:for-each>
</table>
So give me all the <item> nodes, display the "label" element in the
first data cell, grab the reference (XPath expression) for the value,
and display that one in the second data cell.
Unfortunately, I can't seem to get it to work - trying to
XSL-transform this with MSXSL keeps telling me that the {$DataRef} is
not a valid XPath expression, that it contains "an illegal token" (but
fails to say WHAT that token is!).
Any ideas?? I must be really either not seeing something very basic,
or something is screwy.....
Any hints are most welcome!!
Marc
================================================================
Marc Scheuner May The Source Be With You!
Bern, Switzerland m.scheuner(at)inova.ch
Technical Details
Message-ID:
<th25d0t9ne2mrsdk1ffn6n8k13ffup6tqq@4ax.com>Path:
arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mailShow Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 1efdc8,9aa8ca08da1fb24f,start X-Google-Attributes: gid1efdc8,public From: Marc Scheuner <no.spam@for.me> Newsgroups: borland.public.csharpbuilder.xml Subject: XSL not working as expected Date: Fri, 18 Jun 2004 08:22:58 +0200 Message-ID: <th25d0t9ne2mrsdk1ffn6n8k13ffup6tqq@4ax.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 195.141.64.252 X-Trace: newsgroups.borland.com 1087539776 195.141.64.252 (17 Jun 2004 23:22:56 -0700) Lines: 76 Path: arc1-ca.pugleaf.net!g2news1.google.com!news1.google.com!news.glorb.com!border1.nntp.dca.giganews.com!border2.nntp.dca.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail