<?xml version="1.0" encoding="utf-8"?>
<t:test xmlns:t="http://xproc.org/ns/testsuite/3.0"
        xml:base="/validate-json-schema-001.xml"
        name="validate-json-schema-001.xml"
        expected="pass">
   <t:info>
      <t:title>validate-json-schema-001</t:title>
      <t:revision-history>
         <t:revision>
            <t:date>2025-01-13</t:date>
            <t:author>
               <t:name>Norm Tovey-Walsh</t:name>
            </t:author>
            <t:description xmlns="http://www.w3.org/1999/xhtml">
               <p>Created test.</p>
            </t:description>
         </t:revision>
      </t:revision-history>
   </t:info>
   <t:description xmlns="http://www.w3.org/1999/xhtml">
      <p>Tests that metadata is correct for JSON schema validation.</p>
   </t:description>
   <t: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"
                      version="3.0">
         <p:output port="result" pipe="report@validation"/>
         <p:validate-with-json-schema name="validation">
            <p:with-input href="../../../3.0-test-suite/test-suite/documents/valid.json"/>
            <p:with-input port="schema"
                          href="../../../3.0-test-suite/test-suite/documents/schema.json"/>
         </p:validate-with-json-schema>
         <p:sink/>
      </p:declare-step>
   </t:pipeline>
   <t:schematron>
      <s:schema xmlns:s="http://purl.oclc.org/dsdl/schematron" 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:metadata">The report doesn’t include metadata.</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='jsonSchemaValidator']">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='https://json-schema.org/draft/2020-12/schema']">The schema type is unexpected.</s:assert>
            </s:rule>
         </s:pattern>
      </s:schema>
   </t:schematron>
   <t:result name="validate-json-schema-001.xml">
      <xvrl:report xmlns:xvrl="http://www.xproc.org/ns/xvrl">
         <xvrl:metadata>
            <xvrl:timestamp>2026-07-21T06:16:46.005749182Z</xvrl:timestamp>
            <xvrl:validator name="jsonSchemaValidator" version="1.5.9"/>
            <xvrl:creator name="XML Calabash" version="3.0.52-SNAPSHOT"/>
            <xvrl:document href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/documents/valid.json"/>
            <xvrl:schema href="file:/woodpecker/src/codeberg.org/xmlcalabash/xmlcalabash3/tests/3.0-test-suite/test-suite/documents/schema.json"
                         schematypens="https://json-schema.org/draft/2020-12/schema"
                         language="JSON"/>
         </xvrl:metadata>
         <xvrl:digest valid="true"
                      fatal-error-count="0"
                      error-count="0"
                      warning-count="0"
                      info-count="0"
                      unspecified-count="0"
                      fatal-error-codes=""
                      error-codes=""
                      warning-codes=""
                      info-codes=""
                      unspecified-codes=""
                      worst="unspecified"/>
      </xvrl:report>
   </t:result>
</t:test>
