<?xml version="1.0" encoding="UTF-8" standalone="yes" ?>
<!DOCTYPE bugzilla SYSTEM "https://www.w3.org/Bugs/Public/page.cgi?id=bugzilla.dtd">

<bugzilla version="5.0.4"
          urlbase="https://www.w3.org/Bugs/Public/"
          
          maintainer="sysbot+bugzilla@w3.org"
>

    <bug>
          <bug_id>3306</bug_id>
          
          <creation_ts>2006-05-31 19:36:31 +0000</creation_ts>
          <short_desc>XPath over a sequence of documents</short_desc>
          <delta_ts>2011-02-23 20:27:53 +0000</delta_ts>
          <reporter_accessible>1</reporter_accessible>
          <cclist_accessible>1</cclist_accessible>
          <classification_id>1</classification_id>
          <classification>Unclassified</classification>
          <product>XML Processing Model</product>
          <component>Pipeline language</component>
          <version>unspecified</version>
          <rep_platform>PC</rep_platform>
          <op_sys>Linux</op_sys>
          <bug_status>CLOSED</bug_status>
          <resolution>FIXED</resolution>
          
          
          <bug_file_loc></bug_file_loc>
          <status_whiteboard></status_whiteboard>
          <keywords></keywords>
          <priority>P2</priority>
          <bug_severity>normal</bug_severity>
          <target_milestone>---</target_milestone>
          
          
          <everconfirmed>1</everconfirmed>
          <reporter name="Norman Walsh">Norman.Walsh</reporter>
          <assigned_to name="Norman Walsh">ndw</assigned_to>
          <cc>todd.gochenour</cc>
          
          

      

      

      

          <comment_sort_order>oldest_to_newest</comment_sort_order>  
          <long_desc isprivate="0" >
    <commentid>9914</commentid>
    <comment_count>0</comment_count>
    <who name="Norman Walsh">Norman.Walsh</who>
    <bug_when>2006-05-31 19:36:31 +0000</bug_when>
    <thetext>What does it mean to evaluate an XPath expression over a sequence of documents?</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>9916</commentid>
    <comment_count>1</comment_count>
    <who name="Norman Walsh">Norman.Walsh</who>
    <bug_when>2006-06-01 13:44:41 +0000</bug_when>
    <thetext>See http://lists.w3.org/Archives/Public/public-xml-processing-model-wg/2006May/0128.html

From: Jeni Tennison &lt;jeni@jenitennison.com&gt;

On this topic, I&apos;d like to be able to do:

   &lt;p:choose&gt;
     &lt;p:input name=&quot;input&quot; ref=&quot;documents&quot; /&gt;
     &lt;p:when test=&quot;input contains one or more documents&quot;&gt;
       ...
     &lt;/p:when&gt;
     &lt;p:otherwise&gt;
       ...
     &lt;/p:otherwise&gt;
   &lt;/p:choose&gt;

If the input documents were assigned to a variable, this would be easy:

   &lt;p:choose&gt;
     &lt;p:input name=&quot;input&quot; select=&quot;$documents&quot; /&gt;
     &lt;p:when test=&quot;count($input) &gt;= 1&quot;&gt;
       ...
     &lt;/p:when&gt;
     &lt;p:otherwise&gt;
       ...
     &lt;/p:otherwise&gt;
   &lt;/p:choose&gt;

I can&apos;t work out how you&apos;d do it under the scheme of providing a context 
node for evaluating XPaths. I guess you&apos;d have to use a separate 
component to do the counting:

   &lt;p:step name=&quot;my:count&quot;&gt;
     &lt;p:with-input name=&quot;input&quot; ref=&quot;documents&quot; /&gt;
     &lt;p:with-output name=&quot;output&quot; label=&quot;count&quot; /&gt;
   &lt;/p:step&gt;
   &lt;p:choose&gt;
     &lt;p:input name=&quot;input&quot; ref=&quot;documents&quot; /&gt;
     &lt;p:param name=&quot;count&quot; context=&quot;count&quot; select=&quot;.&quot; /&gt;
     &lt;p:when test=&quot;$count &gt;= 1&quot;&gt;
       ...
     &lt;/p:when&gt;
     &lt;p:otherwise&gt;
       ...
     &lt;/p:otherwise&gt;
   &lt;/p:choose&gt;

Right?

</thetext>
  </long_desc><long_desc isprivate="0" >
    <commentid>40003</commentid>
    <comment_count>2</comment_count>
    <who name="Todd Gochenour">todd.gochenour</who>
    <bug_when>2010-09-29 19:38:06 +0000</bug_when>
    <thetext>This issue seems to be closest to what I&apos;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&apos;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&apos;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=&apos;true&apos;]
return $c

...I can have

let $c = /documents[criteria=&apos;true&apos;]
let $fieldpaths = /form[@id=&apos;123&apos;]/group[type=&apos;grid&apos;]/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.</thetext>
  </long_desc>
      
      

    </bug>

</bugzilla>