Re: XQuery WG comments on XProc specification

Reference has been made to a message that I sent to a member-only list:

> First, Andrew's email, which the WG largely endorsed:
> 
> http://lists.w3.org/Archives/Member/w3c-xsl-query/2008Jun/0000.html


This message said:

I reviewed the latest XProc draft [1], specifically section 7.2.9, 
p:xquery,  and I have the following concerns:

- no way to pass a single document as the context item
- no mapping to our static and dynamic context
- no way to make reference to an xquery file
- no way to use XQueryX
- I don't understand "The result of the XQuery is a sequence of documents
  constructed from an [XPath 2.0] sequence of elements. Each element in 
the
  sequence is assumed to be the document element of a separate document."


I've rewritten this section to address these issues:

7.2.9 p:xquery

The p:xquery step applies an [XQuery 1.0] query to the sequence of 
documents provided on the source port and the document provided on the 
source-node port.

<p:declare-step type="p:xquery">
     <p:input port="source" sequence="true" primary="true"/>
     <p:input port="source-node" sequence="false" primary="false"/>
     <p:input port="query"/>
     <p:input port="parameters" kind="parameter"/>
     <p:output port="result" sequence="true"/>
     <p:option name="query-uri" />
</p:declare-step>

The sequence of documents provided on the source port is treated as the 
default collection. A document provided on the source-node port is treated 
as the context item. Any parameters passed on the parameters port are used 
to define top-level variables.

If the query-uri option is specified, then the resource indicated by this 
URI is expected to contain the XQuery to be executed. Otherwise, the query 
port must receive a single document. If the document contains an 
xqx:module element, where xqx is bound to http://www.w3.org/2005/XQueryX, 
then this XQueryX document provides the query to be executed. Otherwise, 
the document must contain a c:query element. As an XQuery is not 
necessarily well-formed XML, the text descendants of this element are 
considered the query.

<c:query>
    string
</c:query>

For example:

<c:query>
declare namespace atom="http://www.w3.org/2005/Atom";
/atom:feed/atom:entry
</c:query>


The static context of the XQuery processor is augmented in the following 
way:

Statically known default collection type:       document()*


The dynamic context used in evaluation the query is:

Context item:           document provided by the source-node port
Context position:       1
Context size:           1
Variable values:        The union of the in-scope options and variables 
are available as variable bindings to the XQuery processor.
Function implementations:       The function implementations provided by 
the XQuery processor.
Current dateTime:       implementation-defined value
Implicit timezone:      implementation-defined value
Available documents:    implementation-dependent
Available collections:  implementation-dependent
Default collection:     sequence of documents provided by the source port


The result of the XQuery is used to generate the sequence of documents 
that is returned by this step. Each document node and element node in 
result sequence of the XQuery generates a document in the result sequence. 
It is a dynamic error (err:XC0057) if the sequence that results from an 
XQuery contains items other than document nodes and element nodes.

The base URI of each of the output documents is the base URI of the first 
document in the source port's sequence.


Example:

<p:pipeline xmlns:p="http://www.w3.org/ns/xproc">

<p:xinclude/>

<p:validate-with-xml-schema>
  <p:input port="schema">
    <p:document href="http://example.com/path/to/schema.xsd"/>
  </p:input>
</p:validate-with-xml-schema>

<p:query>
   <p:with-option name="query-uri" select="'countp.xq'" />
   <p:input port="source-node">
      <p:pipe step="validate-with-xml-schema" port="result"/>
   </p:input>
</p:query>

</p:pipeline>


countp.xq:

<count>{count(.//p)}</count>



[1] XProc: An XML Pipeline Language
http://www.w3.org/TR/2008/WD-xproc-20080501/

                                                -- Andrew

--------------------
Andrew Eisenberg
IBM
4 Technology Park Drive
Westford, MA  01886

andrew.eisenberg@us.ibm.com

Received on Wednesday, 2 July 2008 20:10:06 UTC