Once test cases have been defined, the validation suite can be used with any RELAX NG or XSD schema. The primary validation process is managed through XQuery functions, which allow users to address the following:
Example 4. Map schemas to their corresponding test cases
declare variable $sch:schemas as map(*) := map { "bloomsbury-mods": map { "schema": "..\..\content-models\DocBook\schema\bloomsbury-mods.rnc", "test-cases": "bloomsbury-mods-tests" }, "vra-strict-bloomsbury": map { "schema": "..\..\content-models\VRA\schema\vra-strict-bloomsbury.xsd", "test-cases": "vra-strict-bloomsbury-tests" }, "bmyTEI-tests": map { "schema": "..\..\content-models\TEI\schema\bmyTEI.rnc", "test-cases": "bmyTEI-tests" } };
Example 5. Target a specific schema during the test suite validation process
declare function sch:options($userInput) { let $schema := $sch:schemas($userInput) return $schema };
Additionally, BaseX’s built-in XQuery validation functions are used to assess whether XML documents conform to their corresponding schemas.
Function: validate:xsd-report()
Signature:
validate:xsd-report( $input as item(), $schema as xs:string? := (), $options as map(*) := {} ) as element(report)
Summary:
Validates the XML $input
document against a $schema
and returns warnings, errors and fatal errors as XML.
Function: validate:rng-report()
Signature:
validate:rng-report( $input as item(), $schema as xs:string, $compact as xs:boolean? := {} ) as element(report)
Summary:
Validates the XML $input
document against a $schema
, using the XML or $compact
notation, and returns warnings, errors and fatal errors as XML.