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

selecting a range of nodes

hi,

I am trying to select a range of following siblings using xslt 1.0. consider
the following XML file

<top>
<a1/>
<a2/>
<foo/>
<a3/>
<a4/>
<a5/>
<a6/>
<bar/>
<a7/>
<a8/>
</top>

now, inside this template

<xsl:template match="foo">

I would like to select all the nodes up to the following <bar(if there are
several <bar>s it would be the next one)

it seems quite simple on the face of it but I can't figure out any way to
get close at the moment

TIA

Andy
Aug 3 '07 #1
1 1592
In article <jo******************@fe2.news.blueyonder.co.uk> ,
Andy Fish <aj****@blueyonder.co.ukwrote:
>I am trying to select a range of following siblings using xslt 1.0. consider
the following XML file

<top>
<a1/>
<a2/>
<foo/>
<a3/>
<a4/>
<a5/>
<a6/>
<bar/>
<a7/>
<a8/>
</top>

now, inside this template

<xsl:template match="foo">

I would like to select all the nodes up to the following <bar(if there are
several <bar>s it would be the next one)
It's a bit messy. You want the following-siblings of the foo that
have a following-sibling which is the first bar after the foo. So
set a variable $bar to following-sibling::bar[1], and use

following-sibling::*[generate-id(following-sibling::bar[1]) = generate-id($bar)]

In this case generate-id works better than counting the union because some
of the elements may not have a following bar element.

For more complicated examples you might want to use "Muenchian grouping"
(see Google).

-- Richard
--
"Consideration shall be given to the need for as many as 32 characters
in some alphabets" - X3.4, 1963.
Aug 3 '07 #2

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

Similar topics

2
by: Dag | last post by:
Hi I am pretty much an xml beginner; hopefully someone can easily answer this one... I want to select a node representing a worksheet in an xml document for the Office Web Components spreadsheet....
2
by: Saurabh Sharma | last post by:
Hi, I am using Dom Parsing in Xml. I am the parent node and it has many children and each children has many children. I want to select children with a given name . Is there any method by which we...
1
by: Stefan | last post by:
Hey guys ! Can someone pls help me and tell me how it is possible to Select a Node in 2nd row? I got a treeview which is build like follows: node2.Nodes.Add("blah", "blubb");...
2
by: Tymbow | last post by:
I'm building a web application that is analogous to the Windows XP file explorer in function. The left column contains a TreeView, and the right column a DataGrid populated by selecting TreeView...
7
by: PatrickRThomas | last post by:
I need help selecting nodes while excluding some of them. Here's an example of XML: <my_xml> <all_items> <item> <key>1</key> <name>Item 1</name> </item> <item>
4
by: visu | last post by:
I need a solution to my problem. the problem is I ll have a button in page ... and when i click it .. content of a div tag has to be get selected (i.e what we normally do with mouse to...
2
by: dav61000 | last post by:
I am new to VB.net so I am not sure if there is a good way to do this or not but here is my problem. I have created a form with a TreeView control on it. When the user selects a node from the...
6
by: mistusen | last post by:
in my project,We consider an ad hoc network composed of battery powered mobile nodes. Each of them has got a radio-range (generally uniform for all nodes in the network),which is an abstract...
1
by: DeveloperX | last post by:
Hi, I should probably start with my XML as it makes it easier to explain the problem. <?xml version="1.0" encoding="utf-8" ?> <aa note="top level"> <b1 note="b1"> <c1 note="b1 c1"> <d1...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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:
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
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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.