p:filter 012 (NW)
Tests p:filter that returns a constant.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0"
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>
Result
<number xmlns="http://www.w3.org/2005/xpath-functions"
xmlns:t="http://xproc.org/ns/testsuite/3.0">1</number>
Schematron checks
<s:schema xmlns="http://www.w3.org/1999/xhtml"
xmlns:s="http://purl.oclc.org/dsdl/schematron" xmlns:t="http://xproc.org/ns/testsuite/3.0"
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>
Revision history
- 24 Dec 2024, Norm Tovey-Walsh
- Proposed test.