p:add-xml-base 001 (NW)

Test p:add-xml-base.

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:add-xml-base>
      <p:with-input href="../documents/doc-with-entities.xml"/>
   </p:add-xml-base>
</p:declare-step>

Result

<book xmlns:t="http://xproc.org/ns/testsuite/3.0"
      xml:base="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/documents/doc-with-entities.xml">
   <preface></preface>
   <chapter label="1" xml:base="subdir/chap1.xml"></chapter>
   <chapter label="2" xml:base="chap2.xml"></chapter>
</book>

Schematron checks

<s:schema xmlns="http://www.w3.org/1999/xhtml"
          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:pattern>
      <s:rule context="/">
         <s:assert test="book">Root element is not 'book'.</s:assert>
         <s:assert test="ends-with(book/@xml:base, '/documents/doc-with-entities.xml')">Document element base URI doesn’t have the correct suffix</s:assert>
         <s:assert test="empty(book/preface/@xml:base)">Preface should not have an xml:base attribute</s:assert>
         <s:assert test="book/chapter[@label='1']/@xml:base = 'subdir/chap1.xml'">First chapter has wrong xml:base</s:assert>
         <s:assert test="book/chapter[@label='2']/@xml:base = 'chap2.xml'">Second chapter has wrong xml:base</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

29 Apr 2024, Norm Tovey-Walsh
Created test for p:add-xml-base.