Skip to Content.
Sympa Menu

xom-interest - Re: [XOM-interest] XOM 1.1: XPath

xom-interest AT lists.ibiblio.org

Subject: XOM API for Processing XML with Java

List archive

Chronological Thread  
  • From: John Cowan <jcowan AT reutershealth.com>
  • To: Elliotte Harold <elharo AT metalab.unc.edu>
  • Cc: xom-interest AT lists.ibiblio.org
  • Subject: Re: [XOM-interest] XOM 1.1: XPath
  • Date: Tue, 11 Jan 2005 21:03:39 -0500

Elliotte Harold scripsit:

> An XPath expression applied to a XOM Document should return the same
> information as the same expression applied to the serialized form of
> that Document.

The difficulty is that the value of an XPath expression of type nodeset
is a set of nodes (lower case referring to the XPath data model), whereas
your proposed API returns a set (or rather a sequence, but that's no
problem) of Nodes (title case referring to objects of class Node).
There is no way to reliably map a sequence of Nodes into a sequence of
nodes without examining the tree itself.

Specifically, every non-Text Node corresponds to a single node,
but N consecutive Text Nodes may refer to 1, 2, ... or N nodes.
If k consecutive Text Nodes n_j, n_j+1 ... n_j+k-1 in the result are
consecutive siblings in the tree, then they are part of the same node;
if not, not.

> In other words, take a XOM document, query it with an XPath expression,
> print out the resulting nodes with toXML.
>
> Take the same XOM document; serialize it; query the serialized form of
> an XML document with the same XPath expression using a tool like Alex
> Chafee's XPath Explorer.
>
> You should get the same results in both cases.

That depends on whether the tool produces the XML representations of
the nodesets with no intervening delimiters. If so, yes; if not, no.
In principle the answers are quite different.

--
Where the wombat has walked, John Cowan <jcowan AT reutershealth.com>
it will inevitably walk again. http://www.ccil.org/~cowan




Archive powered by MHonArc 2.6.24.

Top of Page