472,353 Members | 1,849 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

getting parent node using XLST

Hello,

I am having trouble getting the parent node of an xml document using xslt.

I am trying to return the node wine, but this does not return wine but the
element values under wine.
I thouht this would work. I am looking for the prices context and then ask
for the parent node right?

What am I doing wrong? Thanks in advance for your help.
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="2.0">

<xsl:template match="prices">

parent is: <xsl:value-of select="parent::node"/>

</xsl:template>

</xsl:stylesheet>

<wine>
<winery>Los Vascos</winery>
<year>1998</year>
<prices>
<list>13.99</list>
<discounted>11.99</discounted>
<case>143.50</case>
</prices>
</wine>


Jul 20 '05 #1
2 14793
john smith (pr**************@charter.net) wrote:
: Hello,

: I am having trouble getting the parent node of an xml document using xslt.

: I am trying to return the node wine, but this does not return wine but the
: element values under wine.
: I thouht this would work. I am looking for the prices context and then ask
: for the parent node right?

: What am I doing wrong? Thanks in advance for your help.
: <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
: version="2.0">

: <xsl:template match="prices">

: parent is: <xsl:value-of select="parent::node"/>
select=".."
: </xsl:template>

: </xsl:stylesheet>

: <wine>
: <winery>Los Vascos</winery>
: <year>1998</year>
: <prices>
: <list>13.99</list>
: <discounted>11.99</discounted>
: <case>143.50</case>
: </prices>
: </wine>

--

This space not for rent.
Jul 20 '05 #2


<xsl:value-of select="parent::node"/>

selects all parent elements that have name node.
You meant
<xsl:value-of select="parent::node()"/>
although you could use
<xsl:value-of select=".."/>

The string value of the parent is the concatenation of all the character
data of all the parent's descendants, is that really what you want?

David
Jul 20 '05 #3

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

Similar topics

9
by: jon wayne | last post by:
OK! I had this nagging doubt Consider (without worrying abt access specifiers) class Kid : public Parent{...}; Parent::someFunc() { Kid k;...
2
by: dannielum | last post by:
Hi all, I am trying to write a Binary Search Tree that each of its node will have 3 node pointers: left, right and parent. I need a parent pointer...
4
by: Pavils Jurjans | last post by:
Hello, I am interested in getting the XML contents as text between two XML elements that I know follow each other. They could be in completely...
1
by: clintonG | last post by:
How do I get a TreeNode.Parent property when using the 2.0 TreeView control? When the data source is an XML file there may be redundant names in...
3
by: Hai Nguyen | last post by:
Sorry I don't have code yet. I'm asking for solutions which can help me solve the problem. This is the first time I have to cope this situation,...
6
by: SQACSharp | last post by:
I'm using the EnumChildWindows API with an EnumChildWndProc callback to populate the treeview. The output will be something similar to spy+ + ...
0
by: Guzeppi | last post by:
Hi, i'm using linq to load an xml structure into my classes. the xml consists of the same node nested for multiple levels e.g. <node...
1
by: bnchs | last post by:
This is C code. I am trying to fill each node's Parent field with its parent because I am drawing nodes to the screen. However, I have not been able...
0
by: Dave Mathew | last post by:
I'm in the process of building some navigation for a website. I would like to use the capabilities of the sitemap in asp.net but have ran into some...
0
by: antdb | last post by:
Ⅰ. Advantage of AntDB: hyper-convergence + streaming processing engine In the overall architecture, a new "hyper-convergence" concept was...
0
by: Matthew3360 | last post by:
Hi there. I have been struggling to find out how to use a variable as my location in my header redirect function. Here is my code. ...
2
by: Matthew3360 | last post by:
Hi, I have a python app that i want to be able to get variables from a php page on my webserver. My python app is on my computer. How would I make it...
0
by: Arjunsri | last post by:
I have a Redshift database that I need to use as an import data source. I have configured the DSN connection using the server, port, database, and...
0
hi
by: WisdomUfot | last post by:
It's an interesting question you've got about how Gmail hides the HTTP referrer when a link in an email is clicked. While I don't have the specific...
0
Oralloy
by: Oralloy | last post by:
Hello Folks, I am trying to hook up a CPU which I designed using SystemC to I/O pins on an FPGA. My problem (spelled failure) is with the...
0
by: Carina712 | last post by:
Setting background colors for Excel documents can help to improve the visual appeal of the document and make it easier to read and understand....
0
BLUEPANDA
by: BLUEPANDA | last post by:
At BluePanda Dev, we're passionate about building high-quality software and sharing our knowledge with the community. That's why we've created a SaaS...
0
by: Rahul1995seven | last post by:
Introduction: In the realm of programming languages, Python has emerged as a powerhouse. With its simplicity, versatility, and robustness, Python...

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.