railroad-003
Tests that cx:railroad returns multiple, cross-referenced images.
Test is expected to pass.
The pipeline
<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" name="main" version="3.0">
<p:import href="https://xmlcalabash.com/ext/library/railroad.xpl"/>
<p:output port="result" sequence="true"/>
<cx:railroad inline-literals="false">
<p:with-input>
<p:inline content-type="text/plain">
S ::= A B
A ::= "a"
B ::= B1 | B2
B1 ::= B2
B2 ::= "b"
</p:inline>
</p:with-input>
</cx:railroad>
<p:for-each>
<p:identity>
<p:with-input select="p:document-properties(.)"/>
</p:identity>
<p:cast-content-type content-type="application/xml"/>
</p:for-each>
<p:wrap-sequence wrapper="properties"/>
</p:declare-step>
Result
<properties xmlns:t="http://xproc.org/ns/testsuite/3.0">
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="content-type">image/svg+xml</string>
<string key="cx:nonterminal">S</string>
<string key="cx:ebnf"><div xmlns="http://www.w3.org/1999/xhtml" class="ebnf"><code>
<div><a href="#S" title="S" shape="rect">S</a> ::= <a href="#A" title="A" shape="rect">A</a> <a href="#B" title="B" shape="rect">B</a></div></code></div></string>
<string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/rr-003.xml</string>
</map>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="content-type">image/svg+xml</string>
<array key="cx:referenced-by">
<string>S</string>
</array>
<string key="cx:nonterminal">A</string>
<string key="cx:ebnf"><div xmlns="http://www.w3.org/1999/xhtml" class="ebnf"><code>
<div><a href="#A" title="A" shape="rect">A</a> ::= 'a'</div></code></div></string>
<string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/rr-003.xml</string>
</map>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="content-type">image/svg+xml</string>
<array key="cx:referenced-by">
<string>S</string>
</array>
<string key="cx:nonterminal">B</string>
<string key="cx:ebnf"><div xmlns="http://www.w3.org/1999/xhtml" class="ebnf"><code>
<div><a href="#B" title="B" shape="rect">B</a> ::= <a href="#B1" title="B1" shape="rect">B1</a></div>
<div> | <a href="#B2" title="B2" shape="rect">B2</a></div></code></div></string>
<string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/rr-003.xml</string>
</map>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="content-type">image/svg+xml</string>
<array key="cx:referenced-by">
<string>B</string>
</array>
<string key="cx:nonterminal">B1</string>
<string key="cx:ebnf"><div xmlns="http://www.w3.org/1999/xhtml" class="ebnf"><code>
<div><a href="#B1" title="B1" shape="rect">B1</a> ::= <a href="#B2" title="B2" shape="rect">B2</a></div></code></div></string>
<string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/rr-003.xml</string>
</map>
<map xmlns="http://www.w3.org/2005/xpath-functions">
<string key="content-type">image/svg+xml</string>
<array key="cx:referenced-by">
<string>B</string>
<string>B1</string>
</array>
<string key="cx:nonterminal">B2</string>
<string key="cx:ebnf"><div xmlns="http://www.w3.org/1999/xhtml" class="ebnf"><code>
<div><a href="#B2" title="B2" shape="rect">B2</a> ::= 'b'</div></code></div></string>
<string key="base-uri">file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/rr-003.xml</string>
</map>
</properties>
Schematron checks
<s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron"
xmlns:t="http://xproc.org/ns/testsuite/3.0" queryBinding="xslt2">
<s:ns prefix="svg" uri="http://www.w3.org/2000/svg"/>
<s:ns prefix="fn"
uri="http://www.w3.org/2005/xpath-functions"/>
<s:ns prefix="array"
uri="http://www.w3.org/2005/xpath-functions/array"/>
<s:pattern>
<s:rule context="/">
<s:assert test="properties">Result isn’t a properties document.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/properties">
<s:assert test="count(fn:map) = 5">There are not five maps.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/properties/fn:map[1]">
<s:assert test="fn:string['cx:nonterminal'] = 'S'">The nonterminal is incorrect.</s:assert>
<s:assert test="empty(fn:array[@key = 'cx:referenced-by'])">The references are incorrect.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/properties/fn:map[2]">
<s:assert test="fn:string['cx:nonterminal'] = 'A'">The nonterminal is incorrect.</s:assert>
<s:assert test="exists(fn:array[@key = 'cx:referenced-by'])">The references are absent.</s:assert>
<s:assert test="count(fn:array[@key='cx:referenced-by']/*) = 1">The references are incorrect.</s:assert>
<s:assert test="fn:array[@key='cx:referenced-by'][1] = 'S'">The references are incorrect.</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 30 Jan 2025, Norm Tovey-Walsh
- Created test.