Features: p-validate-with-xsd

validate-xsd-001

Tests that XSD errors are reported in the XVRL.

Test is expected to pass.

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@xml-validation"/>
   <p:validate-with-xml-schema name="xml-validation"
                               assert-valid="false">
      <p:with-input port="source">
         <doc>
            <p>Some paragraph.</p>
         </doc>
      </p:with-input>
      <p:with-input port="schema">
         <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
                    elementFormDefault="qualified">
            <xs:element name="doc">
               <xs:complexType>
                  <xs:sequence>
                     <xs:element minOccurs="1"
                                 ref="title"/>
                     <xs:element minOccurs="0"
                                 maxOccurs="unbounded" ref="p"/>
                  </xs:sequence>
               </xs:complexType>
            </xs:element>
            <xs:element name="title" type="xs:string"/>
            <xs:element name="p" type="xs:string"/>
         </xs:schema>
      </p:with-input>
   </p:validate-with-xml-schema>
   <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.401355155Z</xvrl:timestamp>
      <xvrl:validator name="Saxon EE" version="12.7"/>
      <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-xsd-001.xml"/>
      <xvrl:schema href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-xsd-001.xml"
                   schematypens="http://www.w3.org/2001/XMLSchema" language="1.1"/>
   </xvrl:metadata>
   <xvrl:detection xmlns:s="http://saxon.sf.net/"
                   s:constraint-name="cvc-complex-type" s:constraint-clause="2.4"
                   s:constraint-reference="cvc-complex-type.2.4" s:schema-part="1" severity="error"
                   code="FORG0001">
      <xvrl:location href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/extra-suite/test-suite/tests/validate-xsd-001.xml"
                     line="32" column="58"
                     xpath="/Q{}doc[1]/Q{}p[1]"/>
      <xvrl:message>In content of element <doc>: The content model does not allow element <p> to appear as the first child. It must be preceded by <Q{}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="FORG0001" 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:ns prefix="saxon" uri="http://saxon.sf.net/"/>
   <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:assert test="xvrl:detection[@severity='error'                            and @saxon:constraint-name='cvc-complex-type']">The constraint name isn’t correct</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='Saxon EE']">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://www.w3.org/2001/XMLSchema']">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=1">The error count is wrong</s:assert>
      </s:rule>
   </s:pattern>
</s:schema>

Revision history

10 Jan 2025, Norm Tovey-Walsh
Created test.