Lists Home |
Date Index |
This is actually something similar to what I intend to implement over an XML
Repository [probably Xindice].
We have a requirement to be able to; given a node, find all annotations [of
a particular type or matching certain criteria], on that node.
While I want to be able to express this as an Axis in the XPath object
model, I've got a few problems with that:
1. How do I specify the Annotation context for the annotation axis. Our
annotations are stored as standoff annotations, and to complicate things
further, may apply to either a single document or a collection of documents.
2. It's a heck of a lot easier to create a new XPath function in existing
public domain XPath implementations than it is to change the parsing and
3. The association between a node and it's annotation isn't totally clear.
Does a node have an annotation if the annotation directly specifies the
node? That's easy -- yes. Does the node have an annotation if it's
ancestor has an annotation? That's not very clear, although I lean towards
yes. So, then I really want to axes, the annotation:: axis which returns
the former, and the annotation-closure:: axis, which returns the latter.
This became to complicated for what I required in the short run, so, I've
made a design decision that we'll probably have to go the function route.
What I came up with for an API was:
node-set extension:annot(node-set source [, string tag])
Returns the node-set consisting of all annotations on source. If tag is
supplied, then only those annotations whose element name matches it will be
returned. The value of tag is a list of tags to be included in the result,
separated by white space or | symbols [NOTE: What I really wanted to pass in
to this function here was a relative location path so that I could optimize
So expr[extension:annot(.,"tag")] returns anly those nodes which have a
<tag> annotation, and expr[extension:annot(./ancestor-or-self,"tag")]
selects a similar set, save that the annotation can be on the nodes or its
ancestors. I didn't feel it necessary to have a function that automatically
applied the ancestor-or-self notion simply because the number of ancestors
is going to be small [3-7] for any given node I have to apply this to in our
system, however, I may change my mind once I start implementing.
Of course, I still haven't figured out how to set the context up yet for
annotations, but still I have a few weeks to do some more design.
Engineering is what happens when science and
mathematics meet politics. Products are what
happens when all three meet reality.
From: Jeni Tennison [mailto:firstname.lastname@example.org]
Sent: Sunday, October 06, 2002 1:17 PM
Cc: Eric van der Vlist; email@example.com
Subject: Re: [xml-dev] Annotations in XPath-NG? (Re: [xml-dev]
XPath/XSLT 2.0 concerns)
> My foirst comment is that it should be generic annotation, not just
> type annotation. My thoughts would be:
> Add an "annotation" property to each node. This is a simple
> key/value pair where the key is URI (or is that anathema ;-) ) and
> the value is any XPath 1.0 object (which would even allow
> annotations to be cross-node links).
> You can access any particular annotation for any particular XPath
> object with a function lookup(annoitation-key). Of course, some
> facilities, such as optimizers, might use annotations behind the
> scenes, directly.
> Does this sound like a good general approach?
Definitely. This is very close to what David Rosenborg and I were
Personally I'd use qualified names rather than URIs for the "lookup",
but that's because I envisage getting to annotation information
through an axis rather than through a function and because QNames are
easier to write than URIs. Perhaps a function:
that returns a node set, and let the user use XPath mechanisms for
doing the lookup within that node set?
The xml-dev list is sponsored by XML.org <http://www.xml.org>, an
initiative of OASIS <http://www.oasis-open.org>
The list archives are at http://lists.xml.org/archives/xml-dev/
To subscribe or unsubscribe from this list use the subscription