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

Uniqueness operator for XPath?

  • From: "Clark C. Evans" <cce@c...>
  • To: xml-dev@l...
  • Date: Thu, 08 Feb 2001 13:41:08 -0500 (EST)

xpath unique

I've been thinking a while now that a uniqueness
operator would be very useful addition to XPath.
Often times, a parent node is really a mapping,
that is, there is at most one child of each type:

  <html>
    <head>
      <title>
      ...

In this case, "head" and "title" are unique within
their parent context.  However, the Xpath expression

 /html/head/title 

Does not necessarly encode this assumption of
uniqueness which the user has.  If a schema is 
verifying this fact is available (even if it is
in the user's head), then the above can be safely
re-written as:
  
  /html/head[1]/title[1]

Some processors might even get performance benefits from
this re-write since they must only look at the first child.  
However, the above syntax still does not encode that the user
of the XPath expression only expects a singular value!
Thus, I've been thinking of a uniqueness specifier
(much like an attribute specifier), which allows this
information to be conveyed:

  /html/!head/!title

With the above "extended-xpath" it is clear that I
want _only_ the first head, and within that, the first
title.  Further, and more important, it encodes that the
XPath author does not expect two or more head or title
elements.  This would allow a "debug-mode" XSLT to 
toss an error if this assumption was invalid.  

Thoughts?  I suppose you may think that this should be
in the realm of schema, but I'm not so sure.  It is
rather fundamental.

Kind Regards,

Clark


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.