Skip to content

Commit

Permalink
Raise static errors; add versions that work dynamically
Browse files Browse the repository at this point in the history
  • Loading branch information
ndw committed Dec 6, 2024
1 parent bebab74 commit c3ff299
Show file tree
Hide file tree
Showing 4 changed files with 164 additions and 47 deletions.
25 changes: 12 additions & 13 deletions test-suite/tests/nw-import-functions-002.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass" features="xquery-function-import"
<t:test expected="fail" code="err:XS0107"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-import-functions-002</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>This test should fail statically.</p>
</t:description>
</t:revision>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
Expand Down Expand Up @@ -34,7 +44,7 @@
</p:with-input>
</p:identity>
<p:catch xmlns:err="http://www.w3.org/ns/xproc-error"
code="err:XD0083">
code="err:XS0107">
<p:identity>
<p:with-input>
<correct/>
Expand All @@ -44,15 +54,4 @@
</p:try>
</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:pattern>
<s:rule context="/">
<s:assert test="correct">The document root is not correct.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
68 changes: 68 additions & 0 deletions test-suite/tests/nw-import-functions-002b.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass" xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-import-functions-002b</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Adapted so that it can fail dynamically.</p>
</t:description>
</t:revision>
<t:revision>
<t:date>2024-12-06</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:import-functions.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:import-functions: tests limiting XQuery imports by namespace.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://xproc.org/ns/testsuite/3.0/function-test">
<p:import-functions href="../documents/xquery-library.xq"
namespace="http://example.com/1 http://example.com/1"
content-type="application/xquery" />
<p:output port="result" />

<p:choose>
<p:when test="function-lookup(xs:QName('test:function1'), 0)">
<p:identity>
<p:with-input>
<incorrect/>
</p:with-input>
</p:identity>
</p:when>
<p:otherwise>
<p:identity>
<p:with-input>
<correct/>
</p:with-input>
</p:identity>
</p:otherwise>
</p:choose>
</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:pattern>
<s:rule context="/">
<s:assert test="correct">The document root is not correct.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
50 changes: 16 additions & 34 deletions test-suite/tests/nw-import-functions-003.xml
Original file line number Diff line number Diff line change
@@ -1,9 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass" features="xquery-function-import"
<t:test expected="fail" code="err:XS0107"
xmlns:err="http://www.w3.org/ns/xproc-error"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-import-functions-003</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
<t:name>Norm Tovey-Walsh</t:name>
</t:author>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>This test should fail statically.</p>
</t:description>
</t:revision>
<t:revision>
<t:date>2024-12-06</t:date>
<t:author>
Expand All @@ -25,42 +35,14 @@
xmlns:test1="http://xproc.org/ns/testsuite/3.0/function-test1">
<p:import-functions href="../documents/xslt-functions.xsl"
namespace="http://xproc.org/ns/testsuite/3.0/function-test1"
content-type="application/xslt" />
content-type="application/xslt+xml" />
<p:output port="result" />

<p:try>
<p:identity>
<p:with-input>
<p:identity>
<p:with-input>
<result>{test:function1()}</result>
</p:with-input>
</p:identity>
<p:catch xmlns:err="http://www.w3.org/ns/xproc-error"
code="err:XD0083">
<p:identity>
<p:with-input>
<correct/>
</p:with-input>
</p:identity>
</p:catch>
</p:try>

<p:insert position="last-child">
<p:with-input port="insertion">
<result>{test1:function1()}</result>
</p:with-input>
</p:insert>
</p:with-input>
</p:identity>
</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:pattern>
<s:rule context="/">
<s:assert test="correct">The document root is not correct.</s:assert>
<s:assert test="correct/result/namespaced-function">Result doesn’t include test1:function1 output</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>
68 changes: 68 additions & 0 deletions test-suite/tests/nw-import-functions-003b.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
<?xml version="1.0" encoding="UTF-8"?>
<t:test expected="pass" features="xquery-function-import"
xmlns:t="http://xproc.org/ns/testsuite/3.0">
<t:info>
<t:title>nw-import-functions-003</t:title>
<t:revision-history>
<t:revision>
<t:date>2024-12-06</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:import-functions.</p>
</t:description>
</t:revision>
</t:revision-history>
</t:info>
<t:description xmlns="http://www.w3.org/1999/xhtml">
<p>Tests p:import-functions: tests limiting XSLT imports by namespace.</p>
</t:description>
<t:pipeline>
<p:declare-step version="3.0"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:test="http://xproc.org/ns/testsuite/3.0/function-test"
xmlns:test1="http://xproc.org/ns/testsuite/3.0/function-test1">
<p:import-functions href="../documents/xslt-functions.xsl"
namespace="http://xproc.org/ns/testsuite/3.0/function-test1"
content-type="application/xslt+xml" />
<p:output port="result" />

<p:choose>
<p:when test="function-lookup(xs:QName('test:function1'), 0)">
<p:identity>
<p:with-input>
<incorrect/>
</p:with-input>
</p:identity>
</p:when>
<p:otherwise>
<p:identity>
<p:with-input>
<correct/>
</p:with-input>
</p:identity>
</p:otherwise>
</p:choose>

<p:insert position="last-child">
<p:with-input port="insertion">
<result>{test1:function1()}</result>
</p:with-input>
</p:insert>
</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:pattern>
<s:rule context="/">
<s:assert test="correct">The document root is not correct.</s:assert>
<s:assert test="correct/result/namespaced-function">Result doesn’t include test1:function1 output</s:assert>
</s:rule>
</s:pattern>
</s:schema>
</t:schematron>
</t:test>

0 comments on commit c3ff299

Please sign in to comment.