pack 008

Testing the new (in 3.1) attributes option on p:pack

Test ab-pack-008.xml is expected to pass.

The pipeline


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" version="3.0">
   <p:output port="result"/>
   <p:pack wrapper="wrapper" attributes="map{'pairs': true()}">
      <p:with-input port="source">
         <doc1/>
         <doc2/>
         <doc3/>
      </p:with-input>
      <p:with-input port="alternate">
         <doc-a/>
         <doc-b/>
         <doc-c/>
      </p:with-input>
   </p:pack>
   <p:wrap-sequence wrapper="sequence-wrapper"/>
</p:declare-step>

Schematron validation


<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:pattern>
      <s:rule context="/">
         <s:assert test="sequence-wrapper">The document root is not sequence-wrapper.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[1]/@pairs = 'true'">wrapper[1] pairs attribute is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[1]/*[1][local-name()='doc1']">wrapper[1]/*[1] is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[1]/*[2][local-name()='doc-a']">wrapper[1]/*[2] is not correct.</s:assert>
         <s:assert test="count(sequence-wrapper/wrapper[1]/*)=2">wrapper[1] does not have exactly 2 child elements.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[2]/@pairs = 'true'">wrapper[2] pairs attribute is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[2]/*[1][local-name()='doc2']">wrapper[2]/*[1] is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[2]/*[2][local-name()='doc-b']">wrapper[2]/*[1] is not correct.</s:assert>
         <s:assert test="count(sequence-wrapper/wrapper[2]/*)=2">wrapper[2] does not have exactly 2 child elements.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[3]/@pairs = 'true'">wrapper[3] pairs attribute is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[3]/*[1][local-name()='doc3']">wrapper[3]/*[1] is not correct.</s:assert>
         <s:assert test="sequence-wrapper/wrapper[3]/*[2][local-name()='doc-c']">wrapper[3]/*[1] is not correct.</s:assert>
         <s:assert test="count(sequence-wrapper/wrapper[3]/*)=2">wrapper[3] does not have exactly 2 child elements.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

01 Feb 2025, Norm Tovey-Walsh

Created test.