[
Lists Home 
Date Index 
Thread Index
]
Paul T wrote:
> > hang on a minute.. :) There are counterexamples. See the link below for
> > a formal specification XPath.
> > http://cm.belllabs.com/cm/cs/who/wadler/papers/xpathsemantics/
> xpathsemantics.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 ancestorofself ?
>
> 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[[ ancestororself ]] x = parent*(x)
A[[ descendantsorself ]] 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[[ followingsibling ]] x = nextSibling+(x)
A[[ precedingsibling ]] 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
