validate-rng-001
The pipeline
<p:declare-step xmlns:cx="http://xmlcalabash.com/ns/extensions"
xmlns:err="http://www.w3.org/ns/xproc-error" xmlns:p="http://www.w3.org/ns/xproc"
xmlns:t="http://xproc.org/ns/testsuite/3.0" version="3.0">
<p:output port="result" pipe="report@validation"/>
<p:validate-with-relax-ng name="validation"
assert-valid="false">
<p:with-input port="source">
<doc id="foo bar">
<q>This is a test</q>
</doc>
</p:with-input>
<p:with-input port="schema" expand-text="false">
<p:inline content-type="application/relax-ng-compact-syntax">
start = doc
doc = element doc {
attribute id { xsd:NCName },
attribute class { text }?,
p+
}
p = element p { text }
</p:inline>
</p:with-input>
</p:validate-with-relax-ng>
<p:sink/>
</p:declare-step>
Result
<xvrl:report xmlns:t="http://xproc.org/ns/testsuite/3.0"
xmlns:xvrl="http://www.xproc.org/ns/xvrl">
<xvrl:metadata>
<xvrl:timestamp>2025-06-19T18:02:48.293273583Z</xvrl:timestamp>
<xvrl:validator name="Jing" version="unknown"/>
<xvrl:creator name="XML Calabash"
version="3.0.5-SNAPSHOT"/>
<xvrl:document href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-rng-001.xml"/>
<xvrl:schema href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-rng-001.xml"
schematypens="http://relaxng.org/ns/structure/1.0" language="RNC">
start = doc
doc = element doc {
attribute id { xsd:NCName },
attribute class { text }?,
p+
}
p = element p { text }
</xvrl:schema>
</xvrl:metadata>
<xvrl:detection severity="error">
<xvrl:location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-rng-001.xml"
line="1" column="150"/>
<xvrl:message>value of attribute "id" is invalid; must be an XML name without colons</xvrl:message>
</xvrl:detection>
<xvrl:detection severity="error">
<xvrl:location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-rng-001.xml"
line="2" column="16"/>
<xvrl:message>element "q" not allowed anywhere; expected element "p"</xvrl:message>
</xvrl:detection>
<xvrl:detection severity="error">
<xvrl:location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-rng-001.xml"
line="3" column="17"/>
<xvrl:message>element "doc" incomplete; missing required element "p"</xvrl:message>
</xvrl:detection>
<xvrl:digest valid="false" fatal-error-count="0"
error-count="3" warning-count="0" info-count="0"
unspecified-count="0" fatal-error-codes="" error-codes=""
warning-codes="" info-codes="" unspecified-codes=""
worst="error"/>
</xvrl:report>
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="xvrl"
uri="http://www.xproc.org/ns/xvrl"/>
<s:pattern>
<s:rule context="/">
<s:assert test="xvrl:report">The result isn’t a report.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/xvrl:report">
<s:assert test="xvrl:digest">The report doesn’t include a digest.</s:assert>
<s:assert test="xvrl:detection[@severity='error']">The result doesn’t include an error</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/xvrl:report/xvrl:metadata">
<s:assert test="xvrl:timestamp">The metadata isn’t timestamped.</s:assert>
<s:assert test="xvrl:validator">The metadata doesn’t include the validator.</s:assert>
<s:assert test="xvrl:validator[@name='Jing']">The validator is unexpected.</s:assert>
<s:assert test="xvrl:creator">The metadata doesn’t include the creator.</s:assert>
<s:assert test="xvrl:creator[@name='XML Calabash']">The creator is unexpected.</s:assert>
<s:assert test="xvrl:schema">The metadata doesn’t include the schema.</s:assert>
<s:assert test="xvrl:schema[@schematypens='http://relaxng.org/ns/structure/1.0']">The schema type is unexpected.</s:assert>
</s:rule>
</s:pattern>
<s:pattern>
<s:rule context="/xvrl:report/xvrl:digest">
<s:assert test="@warning-count=0">The warning count is wrong</s:assert>
<s:assert test="@error-count=3">The error count is wrong</s:assert>
</s:rule>
</s:pattern>
</s:schema>
Revision history
- 10 Jan 2025, Norm Tovey-Walsh
Created test.