[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Uniqueness operator for XPath?
- From: "Clark C. Evans" <firstname.lastname@example.org>
- To: email@example.com
- Date: Thu, 08 Feb 2001 13:41:08 -0500 (EST)
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:
In this case, "head" and "title" are unique within
their parent context. However, the Xpath expression
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
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:
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