Features: p-xsl-formatter

Test nw-xsl-formatter-001

Tests that p:xsl-formatter (appears to) work. There’s no actual attempt to test the result.

Test is expected to pass.

The pipeline

<p:declare-step xmlns:err="http://www.w3.org/ns/xproc-error"
                xmlns:p="http://www.w3.org/ns/xproc"
                xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
   <p:output port="result"/>
   <p:xsl-formatter content-type="application/pdf">
      <p:with-input port="source">
         <fo:root xmlns="http://www.w3.org/1999/xhtml"
                  xmlns:fo="http://www.w3.org/1999/XSL/Format">
            <fo:layout-master-set>
               <fo:simple-page-master margin-bottom="0.125in"
                                      margin-left="0.125in"
                                      margin-right="0.125in"
                                      margin-top="0.125in"
                                      master-name="personal-envelope"
                                      page-height="3.625in"
                                      page-width="6.375in">
                  <fo:region-body margin-bottom="0in"
                                  margin-top="0in"/>
               </fo:simple-page-master>
               <fo:simple-page-master margin-bottom="0.125in"
                                      margin-left="0.125in"
                                      margin-right="0.125in"
                                      margin-top="0.125in"
                                      master-name="business-envelope"
                                      page-height="4.125in"
                                      page-width="9.5in">
                  <fo:region-body margin-bottom="0in"
                                  margin-top="0in"/>
               </fo:simple-page-master>
               <fo:page-sequence-master master-name="personal">
                  <fo:repeatable-page-master-alternatives>
                     <fo:conditional-page-master-reference master-reference="personal-envelope"
                                                           odd-or-even="odd"/>
                     <fo:conditional-page-master-reference master-reference="personal-envelope"
                                                           odd-or-even="even"/>
                  </fo:repeatable-page-master-alternatives>
               </fo:page-sequence-master>
               <fo:page-sequence-master master-name="business">
                  <fo:repeatable-page-master-alternatives>
                     <fo:conditional-page-master-reference master-reference="business-envelope"
                                                           odd-or-even="odd"/>
                     <fo:conditional-page-master-reference master-reference="business-envelope"
                                                           odd-or-even="even"/>
                  </fo:repeatable-page-master-alternatives>
               </fo:page-sequence-master>
            </fo:layout-master-set>
            <fo:page-sequence master-reference="business">
               <fo:flow flow-name="xsl-region-body">
                  <fo:block>
                     <fo:block>John Smith</fo:block>
                     <fo:block linefeed-treatment="preserve">123 Main Street</fo:block>
                     <fo:block>Anytown, SA  12345</fo:block>
                  </fo:block>
                  <fo:block margin-left="4in"
                            margin-top="1in">
                     <fo:block>Jane Doe</fo:block>
                     <fo:block linefeed-treatment="preserve">456 Random Street
Suite 200</fo:block>
                     <fo:block>Othertown, OA  67890</fo:block>
                  </fo:block>
               </fo:flow>
            </fo:page-sequence>
         </fo:root>
      </p:with-input>
   </p:xsl-formatter>
   <p:identity>
      <p:with-input select="p:document-properties(.)"/>
   </p:identity>
   <p:cast-content-type content-type="application/xml"/>
</p:declare-step>

Result

<map xmlns="http://www.w3.org/2005/xpath-functions"
     xmlns:t="http://xproc.org/ns/testsuite/3.0">
   <string key="content-type">application/pdf</string>
   <string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/tests/nw-xsl-formatter-001.xml</string>
</map>

Schematron checks

<s:schema xmlns:err="http://www.w3.org/ns/xproc-error"
          xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
          queryBinding="xslt2">
   <s:ns prefix="fn"
         uri="http://www.w3.org/2005/xpath-functions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="fn:map">Root element is not 'map'.</s:assert>
         <s:assert test="fn:map/fn:string[@key='content-type'] = 'application/pdf'">The content type is not application/pdf</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

28 Dec 2024, Norm Tovey-Walsh
Initial commit.