[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Navigation using XPath

Subject: RE: Navigation using XPath
From: Jarno.Elovirta@xxxxxxxxx
Date: Wed, 13 Nov 2002 12:23:12 +0200
using xpath position
Hi,

> Thanx for the info. But what I want to know is if we don't know the
> exact position of the current element like *[1] how do I go 
> the next or
> previous element from the current position (assuming that I don't know
> the exact position number).

The position() returns the context position, so in *[position() = 1] it refers to the context of selecing all child element nodes, i.e. filters out all nodes whose context position is not 1., i.e. returns the child element; if you have following::*[1], it selects all the elements that follow the current node, then filters out all those whose context position is not 1, i.e. again selecting only the first element that follows the current node.

Position() does *not* return the index of an element; use count(preceding-sibling::*) + 1 to get the index of an element within it's siblings. See <http://localhost/tr/xpath/#function-position> and <http://localhost/tr/xpath/#dt-context-position>.

>Can I say something like 
> 
> *[position()=current()] OR following::*[position()=current()] OR
> preceding::*[position()=current()]

current() returns the current node, not a position. What should the above expression select? The current element or the first following element or the first preceding element? Is

. | following::*[1] | preceding::*[1]

what you're after?

> Will it work ?

Depends what you're after, but basically that will not work, or get you want you want.

Launch documentation auto-daemon...

Jarno - Funker Vogt: Words of Power (Power mix)

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.