Features: p-validate-with-relax-ng

ab-validate-with-relax-ng-006

Basic test, standard grammar: check error is reported.

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" name="pipeline" version="3.0">
   <p:output port="result"/>
   <p:try>
      <p:output port="result"/>
      <p:validate-with-relax-ng>
         <p:with-input port="source">
            <doc>
               <p>Some paragraph.</p>
            </doc>
         </p:with-input>
         <p:with-input port="schema">
            <grammar xmlns="http://relaxng.org/ns/structure/1.0">
               <start>
                  <ref name="doc"/>
               </start>
               <define name="doc">
                  <element name="doc">
                     <ref name="title"/>
                     <zeroOrMore>
                        <ref name="p"/>
                     </zeroOrMore>
                  </element>
               </define>
               <define name="title">
                  <element name="title">
                     <text/>
                  </element>
               </define>
               <define name="p">
                  <element name="p">
                     <text/>
                  </element>
               </define>
            </grammar>
         </p:with-input>
      </p:validate-with-relax-ng>
      <p:catch name="catch">
         <p:output port="result"/>
         <p:identity>
            <p:with-input pipe="error@catch"/>
         </p:identity>
      </p:catch>
   </p:try>
</p:declare-step>

Result

<c:errors xmlns:c="http://www.w3.org/ns/xproc-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">
   <c:error name="!validate-with-relax-ng"
            type="p:validate-with-relax-ng" code="err:XC0155"
            href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/tests/ab-validate-with-relax-ng-006.xml" line="38" column="60">
      <cx:message>RELAX NG validation failed.</cx:message>
      <cx:explanation>It is a dynamic error if the assert-valid option on p:validate-with-relax-ng is
true and the input document is not valid.</cx:explanation>
      <xvrl:report xmlns:xvrl="http://www.xproc.org/ns/xvrl">
         <xvrl:metadata>
            <xvrl:timestamp>2025-06-19T18:06:09.456367276Z</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/3.0-test-suite/test-suite/tests/ab-validate-with-relax-ng-006.xml"/>
            <xvrl:schema href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/tests/ab-validate-with-relax-ng-006.xml"
                         schematypens="http://relaxng.org/ns/structure/1.0" language="RNG">
               <grammar xmlns="http://relaxng.org/ns/structure/1.0">
                  <start>
                     <ref name="doc"/>
                  </start>
                  <define name="doc">
                     <element name="doc">
                        <ref name="title"/>
                        <zeroOrMore>
                           <ref name="p"/>
                        </zeroOrMore>
                     </element>
                  </define>
                  <define name="title">
                     <element name="title">
                        <text/>
                     </element>
                  </define>
                  <define name="p">
                     <element name="p">
                        <text/>
                     </element>
                  </define>
               </grammar>
            </xvrl:schema>
         </xvrl:metadata>
         <xvrl:detection severity="error">
            <xvrl:location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/tests/ab-validate-with-relax-ng-006.xml"
                           line="2" column="25"/>
            <xvrl:message>element "p" not allowed yet; missing required element "title"</xvrl:message>
         </xvrl:detection>
         <xvrl:digest valid="false"
                      fatal-error-count="0" error-count="1" warning-count="0"
                      info-count="0" unspecified-count="0"
                      fatal-error-codes="" error-codes="" warning-codes=""
                      info-codes="" unspecified-codes=""
                      worst="error"/>
      </xvrl:report>
      <cx:stack-trace>
         <cx:stack-frame type="p:validate-with-relax-ng"
                         name="!validate-with-relax-ng"/>
         <cx:stack-frame type="p:group" name="!group"/>
      </cx:stack-trace>
   </c:error>
</c:errors>

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="c"
         uri="http://www.w3.org/ns/xproc-step"/>
   <s:pattern>
      <s:rule context="/">
         <s:assert test="c:errors">The pipeline root is not “c:errors”.</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jun 2021, Achim Berndzen
Added attribute 'queryBinding' to schematron's schema.
02 Aug 2019, Achim Berndzen
Initial publication