subtree function

It is very difficult to create a node-set containing the union of a node
with its descendants and all namespace and attribute nodes corresponding to
elements in the set.

For example, if I want a node-set to indicate all elements in the subtree
rooted at an identified element E, I could replace

		id("E")

with

		subtree(id("E"))

Furthermore, an empty argument could be taken to mean that the current
context node-set should be used as input (which is a common technique in the
XPath function library).  The prototype would be

node-set subtree(node-set)

and the description would be that the function that unions the input
node-set with all descendant element, text, PI, and comment nodes of nodes
in the node-set to create an intermediate set, then it unions the
intermediate set with namespace and attribute nodes of all elements in the
intermediate set to produce the resulting node-set.

Since XPath allows us to add to the function library, it is easy for me to
define such a function, but it seems useful enough to suggest for a future
version of this specification.

Actually, it would be best if it were made an axis instead because functions
have limited applicability except at the beginning of the expression.  The
function is sufficient for most of the applications I can think of, but it
seems more natural to say

id("E")/subtree::node()

or in the case of a full document

subtree::node()[some filter expression]

However, it is just as easy to say

subtree()[somefilterexpression]

under the assumption that the initial evaluation context indicates the root
node of the document of interest.

John Boyer
Software Development Manager
PureEdge Solutions Inc. (formerly UWI.Com)
Creating Binding E-Commerce
jboyer@PureEdge.com

Received on Wednesday, 7 June 2000 16:03:39 UTC