[
Lists Home |
Date Index |
Thread Index
]
Paul T wrote:
> > hang on a minute.. :) There are counter-examples. See the link below for
> > a formal specification XPath.
> > http://cm.bell-labs.com/cm/cs/who/wadler/papers/xpath-semantics/
> xpath-semantics.pdf
> >
> > This is the clearest spec of XPath I've seen, and much easier to read
> > than the verbose XPath spec. Then again, maybe XPath lends itself to
> > this kind of specification. (denotational semantics)
>
> In the XPath paper that is as a clearest XPath
> spec, where is the keyword ancestor-of-self ?
>
> Are you sure that that paper is an XPath specification?
Wadler's semantics were based on an earlier draft of XPath and
(AFAIK) haven't been updated for the final REC.
The missing axes are pretty easy to specify though, and the
rest of the paper is still accurate.
A[[ ancestor-or-self ]] x = parent*(x)
A[[ descendants-or-self ]] x = children*(x)
We need a few more primitive functions on nodes to define
the others. Each of the following returns a singleton set
or the empty set:
nextSibling :: Node -> Set(Node)
prevSibling :: Node -> Set(Node)
firstChild :: Node -> Set(Node)
With these we can define:
A[[ following-sibling ]] x = nextSibling+(x)
A[[ preceding-sibling ]] x = prevSibling+(x)
A[[ following ]] x = (children* `o` nextSibling+ `o` parent*)(x)
A[[ preceding ]] x = (children* `o` prevSibling+ `o` parent*)(x)
where (f `o` g)(x) == { z : y <- g(x), z <- f(y) }
The P[[ ... ]] and D[[ ... ]] rules for the new axes are obvious.
--Joe English
jenglish@flightlab.com
|