Xpath context

Discussion in 'XML' started by t.cimoli@gmail.com, Apr 4, 2005.

  1. Guest

    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.
    , Apr 4, 2005
    #1
    1. Advertising

  2. writes:

    > 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
    David Carlisle, Apr 4, 2005
    #2
    1. Advertising

  3. Guest

    Thank you. Now it works.
    , Apr 5, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. VS_NET_DEV
    Replies:
    2
    Views:
    3,780
    jenny
    May 25, 2004
  2. =?Utf-8?B?U3VuU21pbGU=?=
    Replies:
    0
    Views:
    684
    =?Utf-8?B?U3VuU21pbGU=?=
    Jan 10, 2006
  3. Flip Rayner
    Replies:
    1
    Views:
    633
    bruce barker
    Jan 23, 2007
  4. asd
    Replies:
    1
    Views:
    417
    www.pulpjava.com
    Nov 9, 2006
  5. Jani Tiainen
    Replies:
    3
    Views:
    998
    Jani Tiainen
    Aug 27, 2007
Loading...

Share This Page