p:xquery 005 (AB)

Tests p:xquery

Test is expected to pass.

Input: source

<authors xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <author>
      <firstname>William</firstname>
      <lastname>Shakespeare</lastname>
   </author>
   <author>
      <firstname>Christopher</firstname>
      <lastname>Marlowe</lastname>
   </author>
   <author>
      <firstname>Ben</firstname>
      <lastname>Johnson</lastname>
   </author>
</authors>

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:input port="source"/>
   <p:output port="result"/>
   <p:xquery xmlns:test="http://www.test.com"
             parameters="map{'str' : 'Will', 'test:str' : 'Chris'}">
      <p:with-input port="query">
         <c:query xmlns:c="http://www.w3.org/ns/xproc-step">
                  declare namespace test = "http://www.test.com";
                  declare variable $str external;
                  declare variable $test:str external;
                  
                  for $author in //author[contains(firstname, $str) or contains(firstname, $test:str)]
                  order by $author/firstname
                  return $author
               </c:query>
      </p:with-input>
   </p:xquery>
   <p:wrap-sequence wrapper="wrapper"/>
</p:declare-step>

Result

<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <author>
      <firstname>Christopher</firstname>
      <lastname>Marlowe</lastname>
   </author>
   <author>
      <firstname>William</firstname>
      <lastname>Shakespeare</lastname>
   </author>
</wrapper>

Schematron checks

<s:schema xmlns="http://www.w3.org/1999/xhtml"
          xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
          queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="wrapper">Root element is not 'wrapper'.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen
Added attribute 'queryBinding' to schematron's schema.
13 Sep 2019, Achim Berndzen
Tests for p:xquery (Partly ported from 1.0)