p:split-sequence-011 (AB)

Tests p:split-sequence accepts any document

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:identity>
      <p:with-input>
         <p:inline>
            <doc/>
         </p:inline>
         <p:inline content-type="text/html">
            <html xmlns="http://www.w3.org/1999/xhtml"/>
         </p:inline>
         <p:inline content-type="text/plain">This is a text.</p:inline>
         <p:inline content-type="application/json">{{"key" : "value"}}</p:inline>
         <p:inline content-type="application/octet-stream">0102030405</p:inline>
      </p:with-input>
   </p:identity>
   <p:split-sequence test="true()" name="splitter"/>
   <p:for-each>
      <p:identity>
         <p:with-input>
            <content-type>{p:document-property(., 'content-type')}</content-type>
         </p:with-input>
      </p:identity>
   </p:for-each>
   <p:wrap-sequence wrapper="matched"
                    name="matched-sequence"/>
   <p:for-each>
      <p:with-input pipe="not-matched@splitter"/>
      <p:identity>
         <p:with-input>
            <content-type>{p:document-property(., 'content-type')}</content-type>
         </p:with-input>
      </p:identity>
   </p:for-each>
   <p:wrap-sequence wrapper="not-matched"
                    name="not-matched-sequence"/>
   <p:wrap-sequence wrapper="result">
      <p:with-input pipe="@matched-sequence @not-matched-sequence"/>
   </p:wrap-sequence>
</p:declare-step>

Result

<result xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <matched>
      <content-type>application/xml</content-type>
      <content-type>text/html</content-type>
      <content-type>text/plain</content-type>
      <content-type>application/json</content-type>
      <content-type>application/octet-stream</content-type>
   </matched>
   <not-matched/>
</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="result/matched/content-type[1]/text()='application/xml'">Content type is not 'application/xml'.</s:assert>
         <s:assert test="result/matched/content-type[2]/text()='text/html'">Content type is not 'text/html'.</s:assert>
         <s:assert test="result/matched/content-type[3]/text()='text/plain'">Content type is not 'text/plain'.</s:assert>
         <s:assert test="result/matched/content-type[4]/text()='application/json'">Content type is not 'application/json'.</s:assert>
         <s:assert test="result/matched/content-type[5]/text()='application/octet-stream'">Content type is not 'application/octet-stream'.</s:assert>
         <s:assert test="count(result/not-matched/content-type)=0">The should be no elements in 'non-matched'.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen
Added attribute 'queryBinding' to schematron's schema.
24 May 2020, Achim Berndzen
Additional tests for p:split-sequence