AB for-each 013
Tests connections to loop's parent scope.
Test is expected to pass.
Input: source
<doc xmlns:t="http://xproc.org/ns/testsuite/3.0">
<title>Some title</title>
<para>Paragraph 1.</para>
<para>Paragraph 2.</para>
<para>Paragraph 3.</para>
</doc>
The pipeline
<p:declare-step xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" name="pipeline" version="3.0">
<p:input port="source"/>
<p:output port="result" sequence="true"/>
<p:variable name="var" select="42"/>
<p:identity name="producer">
<p:with-input>
<doc/>
</p:with-input>
</p:identity>
<p:for-each>
<p:with-input select="/doc/para">
<p:pipe step="pipeline" port="source"/>
</p:with-input>
<p:add-attribute attribute-name="att"
attribute-value="{$var}">
<p:with-input pipe="@producer"/>
</p:add-attribute>
</p:for-each>
<p:wrap-sequence wrapper="wrapper"/>
</p:declare-step>
Result
<wrapper xmlns:t="http://xproc.org/ns/testsuite/3.0">
<doc att="42"/>
<doc att="42"/>
<doc att="42"/>
</wrapper>
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:pattern>
<s:rule context="/">
<s:assert test="wrapper">The pipeline root is not wrapper.</s:assert>
<s:assert test="count(wrapper/*)=3">Wrapper does not have three children.</s:assert>
<s:assert test="count(wrapper/doc)=3">Wrapper does not have three children named 'doc'.</s:assert>
<s:assert test="wrapper/doc[1]/@att='42'">Value of doc[1]/@att is not 42.</s:assert>
<s:assert test="wrapper/doc[2]/@att='42'">Value of doc[2]/@att is not 42.</s:assert>
<s:assert test="wrapper/doc[3]/@att='42'">Value of doc[3]/@att is not 42.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 10 Jun 2021, Achim Berndzen
- Added attribute 'queryBinding' to schematron's schema.
- 25 May 2019, Achim Berndzen
- Initial test