<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/nw-import-functions-003b.xml"
        name="nw-import-functions-003b.xml"
        expected="pass"
        features="xquery-function-import">
   <t:info>
      <t:title>nw-import-functions-003b</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 xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:test="http://xproc.org/ns/testsuite/3.0/function-test"
                      xmlns:test1="http://xproc.org/ns/testsuite/3.0/function-test1"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      version="3.0">
         <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 xmlns="http://www.w3.org/1999/xhtml"
                xmlns:s="http://purl.oclc.org/dsdl/schematron"
                queryBinding="xslt2">
         <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:result name="nw-import-functions-003b.xml">
      <correct xmlns:test="http://xproc.org/ns/testsuite/3.0/function-test"
               xmlns:test1="http://xproc.org/ns/testsuite/3.0/function-test1"
               xmlns:xs="http://www.w3.org/2001/XMLSchema">
         <result>
            <namespaced-function/>
         </result>
      </correct>
   </t:result>
</t:test>
