p:split-sequence-010 (AB)
Tests p:split-sequence
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 name="one">
<p:with-input port="source">
<one/>
</p:with-input>
</p:identity>
<p:identity name="two">
<p:with-input>
<two/>
</p:with-input>
</p:identity>
<p:split-sequence name="splitter"
test="position() mod 2 = 0">
<p:with-input pipe="@one @one @two @two @one"/>
</p:split-sequence>
<p:wrap-sequence name="matched" wrapper="matched">
<p:with-input pipe="matched"/>
</p:wrap-sequence>
<p:wrap-sequence name="not-matched"
wrapper="not-matched">
<p:with-input pipe="not-matched@splitter"/>
</p:wrap-sequence>
<p:wrap-sequence wrapper="result">
<p:with-input pipe="@matched @not-matched"/>
</p:wrap-sequence>
</p:declare-step>
Result
<result xmlns:t="http://xproc.org/ns/testsuite/3.0">
<matched>
<one/>
<two/>
</matched>
<not-matched>
<one/>
<two/>
<one/>
</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="count(result/matched/*)=2">Element 'matched' does not have two children.</s:assert>
<s:assert test="result/matched/*[1]/name()='one'">First child of 'matched' should be 'one'.</s:assert>
<s:assert test="result/matched/*[2]/name()='two'">Second child of 'matched' should be 'two'.</s:assert>
<s:assert test="count(result/not-matched/*)=3">Element 'not-matched' does not have two children.</s:assert>
<s:assert test="result/not-matched/*[1]/name()='one'">First child of 'not-matched' should be 'one'.</s:assert>
<s:assert test="result/not-matched/*[2]/name()='two'">Second child of 'not-matched' should be 'two'.</s:assert>
<s:assert test="result/not-matched/*[3]/name()='one'">Third child of 'not-matched' should be 'one'.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 10 Jun 2021, Achim Berndzen
- Added attribute 'queryBinding' to schematron's schema.
- 22 May 2019, Achim Berndzen
- Additional tests for p:split-sequence