473,473 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Position of a node

Hallo!

How can find out the postion of a node with a particular content in the
nodeset WITHOUT being in the context?

I would like have something like
<xsl:variable name="position" select="position(/foo/bar[blubber='test'])">
of course position() does not work this way.

Is there another way to solve this?

Many thanks,

Hans

Jul 20 '05 #1
2 3479
The position of *which* node in *what* nodeset?

You haven't specified either.
Also, the XPath position() function is defined on the current *node-list*,
not node-set. This means that position() can be used:

in a relation in predicates within an XPath expression to select nodes
whose position in the current node-list satisfies this relation,

or

in the body of xsl:for-each or of xsl:template to return the position of
the current node in the current node-list.

=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

"Hans-Michael Rupp" <ha*******@danet.de> wrote in message
news:3F**************@danet.de...
Hallo!

How can find out the postion of a node with a particular content in the
nodeset WITHOUT being in the context?

I would like have something like
<xsl:variable name="position" select="position(/foo/bar[blubber='test'])">
of course position() does not work this way.

Is there another way to solve this?

Many thanks,

Hans

Jul 20 '05 #2
Hi Hans,

Depends on what you are actually trying to accomplish?

Crudely...
<xsl:variable name="position" select="position(/foo/bar[blubber='test'])">
Do you want the 'position' of <bar> within all children of the <foo>
element? e.g.
<xsl:variable name="position"
select="count(/foo/bar[blubber='test']/preceding-sibling::*)"/>

Do you want the 'position' of <bar> within all <bar> element children of the
<foo> element? e.g.
<xsl:variable name="position"
select="count(/foo/bar[blubber='test']/preceding-sibling::bar)"/>

etc. etc.

But you may get very unexpected results from the above unless the node you
are starting at (i.e. the part of the expression before the
/preceding-sibling axis) is gauranteed to be a single node.

Hope this helps
Marrow
http://www.marrowsoft.com - home of Xselerator (XSLT IDE and debugger)
http://www.topxml.com/Xselerator
"Hans-Michael Rupp" <ha*******@danet.de> wrote in message
news:3F**************@danet.de... Hallo!

How can find out the postion of a node with a particular content in the
nodeset WITHOUT being in the context?

I would like have something like
<xsl:variable name="position" select="position(/foo/bar[blubber='test'])">
of course position() does not work this way.

Is there another way to solve this?

Many thanks,

Hans

Jul 20 '05 #3

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

Similar topics

1
by: Felix Natter | last post by:
hi, I have a structure like: <topic name="xxx"> <subtopic name="subxxx"> <subsubtopic name="subsubxxx"> </subsubtopic> </subtopic> </topic>
2
by: Angus McIntyre | last post by:
Can this be done with XPath? I have input XML that is basically of the form: <list> <item att="a">s1</item> <item att="a">s2</item> <item att="b">s3</item> <item att="c">s4</item> <item...
4
by: JE | last post by:
Hi! I am snooping around all sorts of websites and faqs, in search of a way to pick up any selected (mouse-highlighted) text in a HTML page, and store it in a JavaScript variable. I have...
0
by: Drake23 | last post by:
Hi, I need your help! I have to appoint the position of the current node in an nodelist. the nodelist I defined in a variable with: <xsl:variable name="CN"...
6
by: Eddy C | last post by:
Hi, I'm trying to get the value of another node using the position of another node or the name of the tag. Such that the current node is one of the contacts child nodes sec or prim and doing...
4
by: Guy | last post by:
Hi, I read an XML file to an XMLDocument and iterate through its nodes. How do I get the XPath position (index) of a certain element? For example If I on the second "b" node I want to get "2": ...
6
by: meh | last post by:
I can figure out the total number of nodes in a given tree but what I'd like to know is what is the Selected Nodes relationship to the entire tree i.e This is node n out of nnn nodes. In most of...
3
by: awebguynow | last post by:
with an xpath expr: step1/step2 I'm trying to get the position() of step2, using the qualifying predicate. I've seen some suggestions, of ways to do this, using count() instead, but I'm not...
5
by: Christof Nordiek | last post by:
When I load a XML-Document from a file, and then get an XmlNode from it, is there any way to get the its original position in the file (line, character)? I want to report it, when there is...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
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
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.