I've just been reviewing the proofs of an article I wrote last year on the
use of XML to represent data derived from historical sources, and I realize
that a passage on the many and wondrous uses of axes has been rendered
obsolete by XPath 2.0 and XQuery. Can someone explain why the ancestor,
preceding-sibling, and following-sibling axes have been dropped?
I found these axes useful in a couple of contexts. My normal practice (in
XSLT) was to identify a unit of analysis and use for-each to iterate at that
level; I could then use ancestor to climb higher in the tree (or do I mean
lower? closer to the root would be more accurate) and fetch data which the
current node had "inherited". The sibling axes were handy for proximity
searches, so that I could study how objects were grouped together, i.e. look
at other leaves sharing the same stem.
I can see ways to achieve the same effect in XQuery, using let and position,
but these seem rather roundabout. If I can be permitted to quote myself
(!): "XPath 'axes' provide the tools to study structural relationships,
navigating the genealogy-like hierarchy of XML data. In addition to the
commonly-used axes of direct descent - ancestors, parents, children and
descendants - there are also axes for siblings, preceding and subsequent
elements, which by extension enable one to relate elements to their 'cousins
'. These tools are of most use when looking at how objects are grouped
together, enabling co-occurrence and sequence to be considered."
Michael Kay is on record as having argued for the preservation of these
axes. Since he lost the debate, the arguments against them must have been
pretty persuasive. What were they? I gather from Michael Brundage's XQuery
book that some implementations are keeping these axes although they are not
required to do so. Why not just keep them within the specification?
Thanks,
Donald Spaeth
Dr Donald Spaeth
Senior Lecturer in Historical Computing
Department of History
2 University Gardens
University of Glasgow
Glasgow G12 8QQ
tel. 0141 330 3580
reply to: d.spaeth@history.arts.gla.ac.uk