OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Uniqueness operator for XPath?




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