[xquery-talk] Selecting Descendants
jhunter at xquery.com
Mon Jun 13 15:06:35 PDT 2005
> I'm seeking a way to select only those descandants in a tree which fit a
> criterion but not their descandants (even if those fit the critirion as
> I know, you can select with //node-name, but that will give back
> children of node-name with name node-name as well and i don't want them
> (got it?)
You *are* in fact only selecting the nodes with those names. Think of
nodes as pointers: you're getting pointers to just those nodes. However
when you *output* those nodes, they're being serialized with their
children. You can't directly break the node away from its children on
serialization. What you can do is for each node matched, construct a
return clause that serializes the important data from the matched node
(i.e. name, attribs, whatever).
With an engine that supports update you could do the update in place.
With MarkLogic for example you could fetch the node, create an in memory
copy, and remove all the children or selective descendants from the copy.
More information about the talk