473,386 Members | 1,828 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

XSL not working as expected....

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
Nov 12 '05 #1
2 1563


Marc Scheuner [MVP ADSI] wrote:

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!).


{$DataRef} is a so called attribute value template you could use as the
attribute value of a literal result element but not as the value of the
select attribute.

There is no dynamic evaluation of strings as XPath expressions in XPath
1.0 which both MSXML and .NET implement currently so your attempt to
have an XPath expression as the text content of an element and evaluate
that in your XSLT stylesheet will not work. If you want to reference
other elements have a look at ID/IDREF attributes and then you can use
the id function in XPath.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #2


Marc Scheuner [MVP ADSI] wrote:

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!).


{$DataRef} is a so called attribute value template you could use as the
attribute value of a literal result element but not as the value of the
select attribute.

There is no dynamic evaluation of strings as XPath expressions in XPath
1.0 which both MSXML and .NET implement currently so your attempt to
have an XPath expression as the text content of an element and evaluate
that in your XSLT stylesheet will not work. If you want to reference
other elements have a look at ID/IDREF attributes and then you can use
the id function in XPath.
--

Martin Honnen
http://JavaScript.FAQTs.com/

Nov 12 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Jeff | last post by:
ok.... i dont know why this wont work. this is going to access DB on web. var1a = Request.Form("h1") var1b = Request.Form("h2") strSQL = "UPDATE matches SET team1a = " & var1a & ", team1b = "...
1
by: Oz | last post by:
This is long. Bear with me, as I will really go through all the convoluted stuff that shows there is a problem with streams (at least when used to redirect stdout). The basic idea is that my...
3
by: Jason S | last post by:
Hello Group, I am just about tearing my hair out with this one and thought someone may have some insight. I have a transform that wasn't working so I grabbed the nearest debugger (xselerator)...
11
by: Tyler Sample | last post by:
I've been having strange thread conflicts, and after moving the relevant mutex higher and higher I've finally determined that the mutex doesn't seem to be working at all. Here is the relevant...
10
by: Scott Richards | last post by:
Hi I am getting a exception while using a datareader here is the code Me.SqlConnection1.Open() Me.SqlReservationCheck.Parameters("@Ref").Value = Ref Dim Reader As SqlClient.SqlDataReader = _...
8
by: WvH | last post by:
Hi, When I create a new application, with just one button, then this code works as expected: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles...
4
by: Jeff | last post by:
I feel like I should have been able to figure this out but I can't seem to find any references on this topic. It seems like my current working directory is consistently a few directories up from...
2
by: Trevor | last post by:
Argh! This problem is driving me nuts! Can you help? In November of 2003, I installed a web service on Windows Server 2003 built in VB.NET for v1.1.4322 of the framework. It contains a timer...
8
by: speralta | last post by:
I'm playing around with a test page that uses a <div id="main"within the context of a body with a width of 100% to center a fixed width field on a page. For some reason, the page is not centering...
3
by: Brad Baker | last post by:
I have a formview with a datasource that contains a select and update command. The select statement works fine but the update command doesn't seem to be working. After some troubleshooting I have...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.