Xpath context

T

t.cimoli

Hi all.
i have a question: xpath queries are allowed only in the current
context?
Every example i find seems so.
For example: i have to count the position of a child respect to its
siblings and i have a pointer to him, but i am in an other place on the
object tree. How can i use the standard query
(count(*[name()=$ObjName]/following-sibling::*) +1 )
on that child - whose pointer is stored under a variable ?-
Thank you everyone.
 
D

David Carlisle

Hi all.
i have a question: xpath queries are allowed only in the current
context?
Every example i find seems so.
For example: i have to count the position of a child respect to its
siblings and i have a pointer to him, but i am in an other place on the
object tree. How can i use the standard query
(count(*[name()=$ObjName]/following-sibling::*) +1 )
on that child - whose pointer is stored under a variable ?-
Thank you everyone.

If $x holds a node set then you can do

(count($x/*[name()=$ObjName]/following-sibling::*) +1 )

to count the following siblings of the child of $x whose name is
$onjName.

David
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,013
Latest member
KatriceSwa

Latest Threads

Top