473,657 Members | 2,371 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.89 7</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="{$DataR ef}" />
</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)i nova.ch
Nov 12 '05 #1
2 1577


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.89 7</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="{$DataR ef}" />
</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.89 7</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="{$DataR ef}" />
</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
1641
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 = " & var1b & " WHERE ID = '1'" Conn.Execute (strSQL)
1
5377
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 application (VB.NET) will start a process, redirect its stdout and capture that process' output, displaying it in a window. I've written a component for this, and a test application for the component. It allows me to specify a command to execute,...
3
2466
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) and saw that it works just fine. Now what I mean by not working is that it just silently fails to produce the expected output... no exceptions are being thrown. Xselerator uses msxml 3 so it's not really helping me see the problem in .net 1.1. ...
11
3068
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 code: private static Mutex previewMutex = new Mutex(); private static void preview (string source, string target) {
10
1859
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 = _ Me.SqlReservationCheck.ExecuteReader() Dim I As Integer() Dim Index As Integer = 0 If Reader.HasRows Then While Reader.Read()
8
5121
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 Button1.Click Dim f As New ColorDialog f.ShowDialog() End Sub
4
3677
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 where I am storing the file - not what I would have expected. I would have expected it to be the same directory as the dir with my code - I guess I was wrong because thats not what is happening. On my own computer it wasn't a big problem...
2
2448
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 (System.Timers.Timer) which has an interval of 24 hours. Actually, it reads a time like 2AM out of the config file, and calculates the time between the start of the service to 2AM, and sets the timer. When the timer expires, it re-reads the...
8
4231
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 in Internet Explorer. What's odd is that it works on my site's home page and most other pages, but not on pages that I am returning from a particular script. I've stripped out most of the content in an attempt to sort it out, but after kicking...
3
4797
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 narrowed the problem down to the department_id parameter which is set from a hidden field. I can confirm this by hard coding the UpdateCommand to: UPDATE configuration SET special_notes=@special_notes WHERE (student_id=@student_id) AND...
0
8312
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8827
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8732
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8504
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6169
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
2732
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1959
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1622
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.