XProc steps

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z

p:xquery

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

With the help of the <p:xquery> step, XQuery procedures can be performed. The document to be processed is read in at the appropriate input port (“source“). The real XQuery call has to be defined at the “query“ input port (e.g. by <p:inline>, but then in a <c:query> element, or by a reference to a XQuery document via <p:document>). In the event that additional parameters have to be assigned to the call, they will be entered at the “parameters“ input port. The result is outputted at the “result“ output port. The query language XQuery is a W3C standard. More information on XQuery can be found at the parsQube homepage.

Example

In the following example a simple XQuery call is performed. Here, all authors shall be outputted.

<?xml version="1.0" encoding="UTF-8"?>
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" xmlns:c="http://www.w3.org/ns/xproc-step" version="1.0">
   <p:input port="source">
      <p:document href="FilmCollection.xml"/>
   </p:input>
   <p:output port="result" sequence="true"/>
   <p:xquery>
      <p:input port="query">
         <p:inline>
            <c:query>/FilmCollection/Film/Author</c:query>
         </p:inline>
      </p:input>
      <p:input port="parameters">
         <p:empty/>
      </p:input>
   </p:xquery>
</p:declare-step>

In the appropriate <c:xquery> element any complex XQuery calls can be defined. However, they have to output a sequence of documents as result. Otherwise, a dynamic error would occur.