p:wrap 014

Tests that setting an xml:base attribute changes the base URI.

Test ab-wrap-014.xml is expected to pass.

The pipeline


<p:declare-step xmlns:p="http://www.w3.org/ns/xproc" name="pipeline" version="3.0">
   <p:output port="result"/>
   <p:wrap match="element" wrapper="wrapper" attributes="map{'wrapped': true(), 'xml:base': 'http://example.com/'}">
      <p:with-input>
         <doc>
            <not-matched/>
            <element/>
            <element/>
            <not-matched/>
         </doc>
      </p:with-input>
   </p:wrap>
   <p:viewport match="wrapper">
      <p:identity>
         <p:with-input select="p:document-properties(.)"/>
      </p:identity>
      <p:cast-content-type content-type="application/xml"/>
   </p:viewport>
</p:declare-step>

Schematron validation


<s:schema xmlns="http://www.w3.org/1999/xhtml" xmlns:s="http://purl.oclc.org/dsdl/schematron" queryBinding="xslt2">
   <s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="doc">Root element is not 'doc'.</s:assert>
         <s:assert test="doc/*[2]/self::fn:map">Second child of 'doc' is not 'fn:map'.</s:assert>
         <s:assert test="doc/*[2]/fn:string[@key='base-uri']                                = 'http://example.com/'">The first base URI is incorrect.</s:assert>
         <s:assert test="doc/*[3]/self::fn:map">Third child of 'doc' is not 'fn:map'.</s:assert>
         <s:assert test="doc/*[3]/fn:string[@key='base-uri']                                = 'http://example.com/'">The second base URI is incorrect.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

01 Feb 2025, Norm Tovey-Walsh

Created test.