Skip to content

Commit

Permalink
Merge pull request #817 from ndw/more-attr
Browse files Browse the repository at this point in the history
Tests for base-uri on new attributes option
  • Loading branch information
ndw authored Feb 1, 2025
2 parents fd71294 + 193d7dc commit bd1e7c3
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 1 deletion.
59 changes: 59 additions & 0 deletions test-suite/tests/ab-pack-009.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>pack 009</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-01</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Created test.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that setting an xml:base attribute changes the base URI.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>
<p:pack wrapper="wrapper" attributes="map{'pairs': true(), 'xml:base': 'http://example.com/'}">
<p:with-input port="source">
<doc1/>
<doc2/>
</p:with-input>
<p:with-input port="alternate">
<doc-a/>
<doc-b/>
</p:with-input>
</p:pack>
<p:for-each>
<p:identity>
<p:with-input select="p:document-properties(.)"/>
</p:identity>
<p:cast-content-type content-type="application/xml"/>
</p:for-each>
<p:wrap-sequence wrapper="sequence-wrapper"/>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron">
<s:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
<s:pattern>
<s:rule context="/">
<s:assert test="sequence-wrapper">The document root is not sequence-wrapper.</s:assert>
<s:assert test="sequence-wrapper/fn:map[1]/fn:string[@key='base-uri']
= 'http://example.com/'">The first base URI is incorrect.</s:assert>
<s:assert test="sequence-wrapper/fn:map[2]/fn:string[@key='base-uri']
= 'http://example.com/'">The second base URI is incorrect.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
2 changes: 1 addition & 1 deletion test-suite/tests/ab-wrap-013.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<t:revision>
<t:date>2025-02-01</t:date>
<t:author>
<t:name>Achim Berndzen</t:name>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Created test.</p>
Expand Down
64 changes: 64 additions & 0 deletions test-suite/tests/ab-wrap-014.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>p:wrap 014</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-01</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Created test.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that setting an xml:base attribute changes the base URI.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<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>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<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>
</t:schematron>
</t:test>
55 changes: 55 additions & 0 deletions test-suite/tests/ab-wrap-sequence-017.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>p:wrap-sequence 017</t:title>
<t:revision-history>
<t:revision>
<t:date>2025-02-01</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests for p:wrap-sequence (Partly ported from 1.0)</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests that setting an xml:base attribute changes the base URI.</p>
</t:description>
<t:pipeline>
<p:declare-step name="pipeline"
version="3.0"
xmlns:p="http://www.w3.org/ns/xproc">
<p:output port="result"/>

<p:wrap-sequence wrapper="sequence"
attributes="map{'seq': true(), 'xml:base': 'http://example.com/'}">
<p:with-input>
<doc/>
<doc/>
<doc/>
</p:with-input>
</p:wrap-sequence>
<p:identity>
<p:with-input select="p:document-properties(.)"/>
</p:identity>
<p:cast-content-type content-type="application/xml"/>
</p:declare-step>
</t:pipeline>
<t:schematron>
<s:schema queryBinding="xslt2"
xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns="http://www.w3.org/1999/xhtml">
<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 'fn:map'.</s:assert>
<s:assert test="fn:map/fn:string[@key='base-uri']
= 'http://example.com/'">The base URI is incorrect.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>

0 comments on commit bd1e7c3

Please sign in to comment.