473,320 Members | 1,724 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,320 software developers and data experts.

XPath.. Getting sibling of ancestor

Hello,

Im wondering about using xml to store relational data. It works well
with .net but im having some trouble with the xsl/xpath.

Lets say that I have an xml like

<data>
<files>
<file categoryid="1" name-"a file"/>
</files>
<filecategories>
<category id="1" name="System Tools"/>
</filecategories>
</data>

how would i do a relational xpath query like a join?

ive tried something like this but its not working to well
<xsl:for-each select="/data/file">
<xsl:value-of select="//category[@id=@categoryid]/@name" />
</xsl:for-each>
ive been reading about using an axis like ancestor::filecategories but
im not seeing an axis which would get the sibling of an ancestor

Aug 28 '06 #1
2 1478
werD wrote:
Hello,

Im wondering about using xml to store relational data. It works well
with .net but im having some trouble with the xsl/xpath.

Lets say that I have an xml like

<data>
<files>
<file categoryid="1" name-"a file"/>
</files>
<filecategories>
<category id="1" name="System Tools"/>
</filecategories>
</data>

how would i do a relational xpath query like a join?

ive tried something like this but its not working to well
<xsl:for-each select="/data/file">
<xsl:value-of select="//category[@id=@categoryid]/@name" />
</xsl:for-each>
ive been reading about using an axis like ancestor::filecategories but
im not seeing an axis which would get the sibling of an ancestor
hi,

try this :
<xsl:for-each select="/data/files/file">
<xsl:value-of select="//category[@id=current()/@categoryid]/@name" />
</xsl:for-each>

--
Cordialement,

///
(. .)
--------ooO--(_)--Ooo--------
| Philippe Poulard |
-----------------------------
http://reflex.gforge.inria.fr/
Have the RefleX !
Aug 28 '06 #2
werD wrote:
Hello,

Im wondering about using xml to store relational data. It works well
with .net but im having some trouble with the xsl/xpath.

Lets say that I have an xml like

<data>
<files>
<file categoryid="1" name-"a file"/>
</files>
<filecategories>
<category id="1" name="System Tools"/>
</filecategories>
</data>

how would i do a relational xpath query like a join?

ive tried something like this but its not working to well
<xsl:for-each select="/data/file">
<xsl:value-of select="//category[@id=@categoryid]/@name" />
</xsl:for-each>
ive been reading about using an axis like ancestor::filecategories but
im not seeing an axis which would get the sibling of an ancestor
ancestor::filecategories/preceding-sibling::filecategories
(or following-sibling).

///Peter
--
XML FAQ: http://xml.silmaril.ie/

Aug 28 '06 #3

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

Similar topics

2
by: Curantil | last post by:
When I look at all the examples every selection like select="child::item" has a constant value to test against ("3" in this case). Can't this be done with a variable? eg: select="child::item" ...
9
by: Jon Thackray | last post by:
I'm trying to use XPath to enable me to number items within sections in a paper. I have so far tried about ten things, all of which it seemed to me should work, and none of which do. Essentially...
2
by: nkunapa | last post by:
Hi: Is there a way in XPATH to find the nearest node of the node in context with a certain attribute value. Here is my problem. I have the following XML and I am trying to add all the nodes with...
7
by: Bill Cohagan | last post by:
I have an XSLT transformation that involves a template with match = "w:p]" What I'm matching on is a w:p element that is: 1.) Within a w:body element (at some level). 2.) Immediately...
1
by: Rob | last post by:
Hi, I am moving through an XML document using an XPath Navigator, and I'd like to be able to get the xpath expression for the location of the current node from the root node. Any ideas how to...
9
by: David Thielen | last post by:
Hi; I am sure I am missing something here but I cannot figure it out. Below I have a program and I cannot figure out why the xpath selects that throw an exception fail. From what I know they...
3
by: Goran Djuranovic | last post by:
Hi All, Does anyone know how to retreive deepest XPath value from XML document by using VB.NET? For example, if I had an XML file like this: <Root> <Customer> <Name>MyName</Name> </Customer>...
3
by: bruce | last post by:
for guys with python/xpath expertise.. i'm playing with xpath.. and i'm trying to solve an issue... i have the following kind of situation where i'm trying to get certain data. i have a...
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...
1
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: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
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: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
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
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.