473,804 Members | 3,446 Online
Bytes | Software Development & Data Engineering Community
+ 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="positio n(/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 3508
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*******@dane t.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="positio n(/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="positio n(/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*******@dane t.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="positio n(/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
2193
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
4295
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 att="c">s5</item>
4
8580
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 found an excellent site which actually has a great cross-platform script for doing just this;
0
3112
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" select="self::node()/parent::node()/child::node()" /> now I have to get the position of the current node in $CN can someone help me, please?
6
1887
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 <xsl:value-of select="//cust/name"/>
4
11562
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": <a> <b/> <c/> <b/> <--- This one
6
14212
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 my database apps its common place to tell the user that they are working on record x of xxx records I'm trying to provide the same functionality using the tree control. TIA meh
3
1632
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 sure count would work. Here's an excerpt from a 2003 post reply by Novatchev ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Also, the XPath position() function is defined on the current *node-list*,
5
8524
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 something odd about that node, so that a user can find the position in the file. Similar to the errormessage from XmlDocument.Load, if the file isn't wellformed XML. If that's not possible, would it be possible when examining the XML with other...
0
9585
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10338
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10323
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9161
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7622
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6856
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5525
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5658
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
3
2997
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.