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

RE: xpath axes

  • From: Adam Van Den Hoven <Adam.Hoven@b...>
  • To: "XML Development Mailing List (E-mail)" <xml-dev@l...>
  • Date: Tue, 16 Jan 2001 16:12:16 -0800

xpath axes
Andrew wrote:
> I am not sure I grasp your point.
> You want something additional to the 
> following-sibling::
> or
> previous-sibling::
> axes mentioned in Section 2 of the XPath Recommendation?

That is exactly my point. I totally understand that I can accomplish the the
effect of a sibling:: axis (as Ken pointed out) but I wasn't thinking of
actually using it at this point. The idea first came about while reading a
particular thread on the XSL list and I was simply curious about why it
wasn't included. 

The more I think about it, the more I think that it may be a useful axis to
have. I honestly don't know how XPath typically gets implemented but it
would seem that the predicate [sibling::node()/@role != self::node/@role]
would be easier to process than [preceding-sibling::node()/@role !=
self::node/@role and following-sibling::node()/@role != self::node/@role]
simply by viture of the fact that the first retrieves one node set and the
other does it twice.

There is also the case where you want to tell someone (like you see at
Amazon) "the majority of people who bought this thing also bought ...". A
part of the path that would be able to tell you these things might be:

/Invoices/Invoice/Item[@partNo='sku2']/sibling::Item

or something more correct. 

If I had the following Library xml
<library>
	<book>
		<author>Adam van den Hove</author>
		<title>somehting</title>
		<publisher>FooBear Press</publisher>
	</book>
	<book>
		<title>Neat Tips</title>
		<publisher>FireBug Press</publisher>
		<author>Adam van den Hove</author>
	</book>
</library>

I really don't care what order my nodes appear in (and if I assumed a
particular order, I would consider that poor programming) and it might be
indeterminant because I scrape the content from a number of different
sources and the tags aren't sorted. So if I wanted to know all the companies
that published my book I could use /library/book/publisher[../author = 'Adam
van den Hoven'] or /library/book/publisher[preceding-sibling::author = 'Adam
van den Hoven' or following-sibling::author = 'Adam van den Hoven'], but it
may be faster (and IMHO more obvious) to write
/library/book/publisher[sibling::author = 'Adam van den Hoven']

Ok, both are a little contrived but I'm sure someone will find a more
relevant use case for it. The fact of the matter is, there are times when
you don't know where a particular node is relative to a node in question so
preceding and following isn't always meaningful. In these cases, it would be
a useful axis to have. 

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
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

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.