This is an archived snapshot of W3C's public bugzilla bug tracker, decommissioned in April 2019. Please see the home page for more details.
What does it mean to evaluate an XPath expression over a sequence of documents?
See http://lists.w3.org/Archives/Public/public-xml-processing-model-wg/2006May/0128.html From: Jeni Tennison <jeni@jenitennison.com> On this topic, I'd like to be able to do: <p:choose> <p:input name="input" ref="documents" /> <p:when test="input contains one or more documents"> ... </p:when> <p:otherwise> ... </p:otherwise> </p:choose> If the input documents were assigned to a variable, this would be easy: <p:choose> <p:input name="input" select="$documents" /> <p:when test="count($input) >= 1"> ... </p:when> <p:otherwise> ... </p:otherwise> </p:choose> I can't work out how you'd do it under the scheme of providing a context node for evaluating XPaths. I guess you'd have to use a separate component to do the counting: <p:step name="my:count"> <p:with-input name="input" ref="documents" /> <p:with-output name="output" label="count" /> </p:step> <p:choose> <p:input name="input" ref="documents" /> <p:param name="count" context="count" select="." /> <p:when test="$count >= 1"> ... </p:when> <p:otherwise> ... </p:otherwise> </p:choose> Right?
This issue seems to be closest to what I'd like to propose. I am looking for a standard way to dynamically evaluate an XPath string from a given context. The evaluate() extension functions fail to accomplish this task. I recommend overloading the node() test function with a variant that takes a path parameter and returns the sequence represented by the parameter. For example, $c/node($path) returns the sequence of nodes relative to $c with the given path resolved. Doesn't this solve the problem with a simple and intuitive enhancement to the XPath specification? The change of evaluation to a template in XSL 2.1 doesn't solve the problem for XQuery. The recommendation above does solve it. With this enhancement, I can have one XML document contain one or more XPath strings used to define the serialization filtering done with the output when querying for another XML document. Instead of the typical: let $c = /documents[criteria='true'] return $c ...I can have let $c = /documents[criteria='true'] let $fieldpaths = /form[@id='123']/group[type='grid']/field/@path return element {name($c)} { for $path in $fieldpaths return $c/node($path) } and this filters the output and thus improves the use of serialization bandwidth.