473,405 Members | 2,310 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,405 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 14859
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 for some the purpose of my project. Without the...
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 different levels, but in XML file the first is...
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 the tree. For example, when a child node with the...
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, hence I'm clueless how to start. I would like to ask...
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+ + How can I specify the parent when adding a new node...
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 id="node_id01" name="node 01"> <node id="node_id0101"...
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 to get this working. Reading the output from the...
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 styling/usability issues in the past using just...
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: 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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.