p:xquery 006 (AB)

Tests p:xquery

Test is expected to pass.

The pipeline

<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" name="pipeline" version="3.0">
   <p:output port="result"/>
   <p:xquery>
      <p:with-input port="source">
         <p:inline document-properties="map{'base-uri' : 'http://xproc-test/primary'}">
            <document>
               <title>Some Title</title>
               <para>Some paragraph.</para>
            </document>
         </p:inline>
         <p:inline document-properties="map{'base-uri' : 'http://xproc-test/secondary'}">
            <document>
               <title>Some Other Title</title>
               <para>Some other paragraph.</para>
            </document>
         </p:inline>
      </p:with-input>
      <p:with-input port="query">
         <c:query xmlns:c="http://www.w3.org/ns/xproc-step">
                  <result>{{collection()}}</result>
               </c:query>
      </p:with-input>
   </p:xquery>
</p:declare-step>

Result

<result xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <document>
      <title>Some Title</title>
      <para>Some paragraph.</para>
   </document>
   <document>
      <title>Some Other Title</title>
      <para>Some other paragraph.</para>
   </document>
</result>

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="result">Root element is not 'result'.</s:assert>
         <s:assert test="count(result/document)=2">Root element does not have 2 children 'document'.</s:assert>
      </s:rule>
      <s:rule context="document[1]">
         <s:assert test="title/text()='Some Title'">Title of document[1] is not 'Some Title'.</s:assert>
         <s:assert test="para/text()='Some paragraph.'">Para of document[1] is not 'Some paragraph.'</s:assert>
      </s:rule>
      <s:rule context="document[2]">
         <s:assert test="title/text()='Some Other Title'">Title of document[2] is not 'Some Other Title'.</s:assert>
         <s:assert test="para/text()='Some other paragraph.'">Para of document[2] is not 'Some other paragraph.'</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

01 Jul 2022, Achim Berndzen
Added base-uri to source documents to make sure every doc in default collection has a different one.
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)