Changes

Jump to navigation Jump to search
60 bytes removed ,  18:34, 1 December 2023
m
Text replacement - "<syntaxhighlight lang="xquery">" to "<pre lang='xquery'>"
* {{Code|validate:dtd('doc.xml', 'doc.dtd')}} validates the document {{Code|doc.xml}} against the specified DTD file {{Code|doc.dtd}}.
* The following example validates an invalid document against a DTD, which is specified as string:
<syntaxhighlight pre lang="'xquery"'>
try {
let $doc := <invalid/>
|
* Pass on document and schema as nodes:
<syntaxhighlight pre lang="'xquery"'>
let $doc := <simple:root xmlns:simple='http://basex.org/simple'/>
let $schema :=
</syntaxhighlight>
* Validate all documents of a database against the specified schema, using the supplied feature:
<syntaxhighlight pre lang="'xquery"'>
for $city in db:get('cities')
return validate:xsd($city, 'city.xsd',
If you want to use Schematron for validating documents, install Vincent Lizzi’s excellent [https://github.com/Schematron/schematron-basex Schematron XQuery Module for BaseX]:
<syntaxhighlight pre lang="'xquery"'>
repo:install('https://github.com/Schematron/schematron-basex/raw/master/dist/schematron-basex-1.2.xar')
</syntaxhighlight>
The following query illustrates how documents are validated. It is directly taken from the GitHub project:
<syntaxhighlight pre lang="'xquery"'>
import module namespace schematron = "http://github.com/Schematron/schematron-basex";
Bureaucrats, editor, reviewer, Administrators
13,550

edits

Navigation menu