<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/nw-filter-012.xml"
        name="nw-filter-012.xml"
        expected="pass">
   <t:info>
      <t:title>p:filter 012 (NW)</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2024-12-24</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Proposed test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests p:filter that returns a constant.</p>
   </t:description>
   <t:pipeline>
      <p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
                      xmlns:xs="http://www.w3.org/2001/XMLSchema"
                      version="3.0">
         <p:output port="result"/>
         <p:option name="select" as="xs:string?" select="'chapter'"/>
         <p:variable name="eq" select="'='"/>
         <p:identity>
            <p:with-input>
               <book>
                  <chapter>Hello, world.</chapter>
                  <appendix>Goodbye, world.</appendix>
               </book>
            </p:with-input>
         </p:identity>
         <p:filter select="count(/book/*[local-name(.) {$eq} '{$select}'])"/>
         <p:cast-content-type content-type="application/xml"/>
      </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:ns prefix="fn" uri="http://www.w3.org/2005/xpath-functions"/>
         <s:pattern>
            <s:rule context="/">
               <s:assert test="fn:number">The result root is not a number.</s:assert>
               <s:assert test="string(.) = '1'">The result is not 1.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="nw-filter-012.xml">
      <number xmlns="http://www.w3.org/2005/xpath-functions">1</number>
   </t:result>
</t:test>
