473,325 Members | 2,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,325 software developers and data experts.

Xpath problems

Hi,

I'm trying to display the data from my typed dataset on a page using
the Xml web control.

I have the following code:
Xm1.Document = new XmlDataDocument(ds);
Using the debugger, I found that the xml representation of my dataset
looks like the following:

[code:1:877c35039f]
<dsData>
<Entry>
<Title>Test</Title>
<Description>This is a test</Description>
</Entry>
</dsData>
[/code:1:877c35039f]

My xsl file looks like this

[code:1:877c35039f]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="dsData/Entry">
<div class="Entry">
<div class="EntryTitle">
<xsl:value-of select="Title"/>
</div>
<div class="EntryDescription">
<xsl:value-of select="Description"/>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl"stylesheet>
[/code:1:877c35039f]

Using this stylesheet, nothing is displayed/transformed. I know that
it must be a stylesheet problem because if I don't set the
TransformSource property of the Xml control the raw xml of the
dataset (XmlDataDocument) is displayed.

I hope that someone understands this, as I'm lost.

Thanks,
Cyp.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 12 '05 #1
5 1238
mw*******@wightman-dot-ca.no-spam.invalid (cyphos) wrote in news:41b60c2e$1
_4@Usenet.com:
My xsl file looks like this

[code:1:877c35039f]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="dsData/Entry">
<div class="Entry">
<div class="EntryTitle">
<xsl:value-of select="Title"/>
</div>
<div class="EntryDescription">
<xsl:value-of select="Description"/>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl"stylesheet>
[/code:1:877c35039f]


Here's the line with the problem:
<xsl:for-each select="dsData/Entry">

Change your XPath to either "/dsData/Entry" or (my preference) "Entry".

-ivan.
Nov 12 '05 #2
Hi,

Thanks for the reply, but unfortunately it didn't solve the problem -
I still don't get any output from the transformation.

Regards,
Cyp.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 12 '05 #3
cyphos wrote:
Hi,

I'm trying to display the data from my typed dataset on a page using
the Xml web control.

I have the following code:
Xm1.Document = new XmlDataDocument(ds);
Using the debugger, I found that the xml representation of my dataset
looks like the following:

[code:1:877c35039f]
<dsData>
<Entry>
<Title>Test</Title>
<Description>This is a test</Description>
</Entry>
</dsData>
[/code:1:877c35039f]

My xsl file looks like this

[code:1:877c35039f]
<?xml version="1.0" encoding="ISO-8859-1"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:template match="/">
<xsl:for-each select="dsData/Entry">
<div class="Entry">
<div class="EntryTitle">
<xsl:value-of select="Title"/>
</div>
<div class="EntryDescription">
<xsl:value-of select="Description"/>
</div>
</div>
</xsl:for-each>
</xsl:template>
</xsl"stylesheet>
[/code:1:877c35039f]

Using this stylesheet, nothing is displayed/transformed. I know that
it must be a stylesheet problem because if I don't set the
TransformSource property of the Xml control the raw xml of the
dataset (XmlDataDocument) is displayed.

I hope that someone understands this, as I'm lost.

Thanks,
Cyp.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*

Are you using catch/try blocks or something? When I try exactly what
you've posted, I get errors on load. But when I removed the
[code:1:877c35039f] blocks, I had no issues with the translation.

Lowell

Nov 12 '05 #4
Hi Lowell,

I'm using the following code in my page load event:
da.Fill(ds);
Xml1.Document = new XmlDataDocument(ds);
Other than that, the page is pretty simple - with just some content
and some data controls (SqlConnection, SqlDataAdapter, and DataSet
objects). What exactly did you remove to get it to work?

Thanks,
Cyp.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 12 '05 #5
Strange, but I got it work. I deleted the dataset, and created a new
one. However, this time I didn't create a typed dataset - and it
worked. I wonder how come it didn't work with a typed dataset?

Anyhow,
This leds to another XPath question, since the structure of my xml
changes.

I have the following xml:

<dsData>
<Entry>
<EntryID>10</EntryID>
<Title>Testing an entry</Title>
</Entry>
<Comment>
<CommentID>1</CommentID>
<EntryID>10</EntryID>
</Comment>
</dsData>
When I'm in a for-each loop that's selecting all Entry elements, I
want to display the total number of Comment elements that have the
current Entry's EntryID.

I have the following, but doesn't work:

[code:1:d4aa569951]
<xsl:for-each select="dsData/Entry">
<!-- other content goes here -->
<value-of select="count(/Comment[EntryID =
{EntryID}])"/>
</xsl:for-each>
[/code:1:d4aa569951]

Thanks!!!!
Cyp.

*-----------------------*
Posted at:
www.GroupSrv.com
*-----------------------*
Nov 12 '05 #6

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

Similar topics

1
by: bdinmstig | last post by:
I refined my attempt a little further, and the following code does seem to work, however it has 2 major problems: 1. Very limited support for XPath features Basic paths are supported for...
13
by: tfsquare | last post by:
All, I am new to XSLT and having some problems understanding the syntax of XPath which selects nodes in the XML document. Consider this bit of XML, which contains three outer XML elements. ...
6
by: Ramon M. Felciano | last post by:
Helo all -- I'm trying to gain a deeper understand for what type of semi-declarative programming can be done through XML and XPath/XSLT. I'm looking at graph processing problems as a testbed for...
2
by: Anna | last post by:
Hi all. I am using Jaxen to evaluate XPath expressions in Java. I encountered problems when comparing results returned by jaxen with results returned by other XPath implementation - I was using...
4
by: Vitali Gontsharuk | last post by:
Hallo! When using the XPATH document() function to load a new XML document, we are coming across problems, because XALAN seems to have problems with absolute paths. XALAN always assumes that the...
2
by: ree32 | last post by:
When I import an xml document in Visual studio and Genereate as schema from it, and create a dataset from it, it adds this line into to the root element of my xml file -...
5
by: Chua Wen Ching | last post by:
Hi, I read from this tutorial at codeproject Question A: http://www.codeproject.com/csharp/GsXPathTutorial.asp regarding xpath.. but i try to apply in my situation, and can't get it...
14
by: Mat| | last post by:
Hello :-) I am learning XPath, and I am trying to get child nodes of a node whose names do *not* match a given string, e.g : <dummy> <example> <title>Example 1</title> <body>this is an...
7
by: Tim Hallwyl | last post by:
Hi, there! As I understand the XPaht recommendation, the context node is a node; not a node-list, not XPath object -- but a single node. Now, the WS-BPEL 2.0 specification allows an XML simple...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.