Simple subtree() function for Xpath transform and c14n

I would like to reiterate that it seems to be easy to clear up the loggerjam
over the subtree() issue because XPath actually allows its applications to
add to the function library.  I just suggested the following function be
added to any future version of XPath, but in the meantime it can be an
addition to c14n and XPath transform serialization:

Function: node-set subtree(node-set)

Unions the argument node-set with all descendant element, text, PI, and
comment nodes of nodes in the argument 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.
If the argument is omitted, it defaults to a node-set with the context node
as its only member.

This trivially solves all of the problems.  For example, the barename
xpointer given by URI="#E" could be represented by the expression

subtree(id("E"))

Further, my own scenarios that involve applying a filter expression to every
node in the entire document is trivially solved by

subtree()[filterexpression]

(This utilizes rule 14 for Expr, reducing to rule 20 with FilterExpr being a
PrimaryExpr followed by a Predicate.)

Naturally, there would be a few more legal XPath expressions if subtree were
an axis, but this seems to suffice for every scenario I've actually run
across.

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:17:41 UTC