| width='120' | '''SignaturesSignature'''|{{Func|validate:dtd|$input as item()|empty-sequence()}}<br /pre>{{Func|validate:dtd|( $input as item(), $schema as xs:string?| := ()) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
* {{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/>
'DTD Validation failed.'
}
</syntaxhighlightpre>
|}
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:dtd-info|$input as item()|xs:string*}}<br /pre>{{Func|validate:dtd-info|( $input as item(), $schema as xs:string?| := ()) as xs:string*}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:dtd-report|$input as item()|element(report)}}<br /pre>{{Func|validate:dtd-report|( $input as item(), $schema as xs:string?| := ()) as element(report)}}</pre>
<message level="Error" line="2" column="11">Element type "invalid" must be declared.</message>
</report>
</syntaxhighlightpre>
|}
==validate:xsd==
{{Announce|Updated with Version 11:}} caching feature added.
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:xsd|$input as item()|empty-sequence()}}<br /pre>{{Func|validate:xsd|( $input as item(), $schema as item()?|empty-sequence()}}<br />{{Func|validate :xsd|$input as item= (), $schema options as itemmap(*)?, $features as := map(*{ })|as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
|Validates the XML {{Code|$input}} document against a {{Code|$schema}}, using the processor-specific . The supported {{Code|$featuresoptions}} are:* {{Code|cache}}: Generated schemas are cached and reused.* All other options are handled as features and passed on to the validator.
|- valign="top"
| '''Errors'''
|
* Pass on document and schema as nodes:
<syntaxhighlight pre lang="'xquery"'>
let $doc := <simple:root xmlns:simple='http://basex.org/simple'/>
let $schema :=
</xs:schema>
return validate:xsd($doc, $schema)
</syntaxhighlightpre>
* Validate all documents of a database against the specified schema, using the supplied feature:
| width='120' | '''SignaturesSignature'''|{{Func|validate:xsd-info|$input as item()|xs:string*}}<br /pre>{{Func|validate:xsd-info|( $input as item(), $schema as item()?|xs :string*}}<br />{{Func|validate:xsd-info|$input as item= (), $schema options as itemmap(*)?, $features as := map(*{ })|as xs:string*}}</pre>
|- valign="top"
| '''Summary'''
|Validates the XML {{Code|$input}} document against a {{Code|$schema}}, using the processor-specific {{Code|$features}}, and returns warnings, errors and fatal errors in a string sequence. See {{Function||validate:xsd}} for more information of the {{Code|$options}} parameter.
|- valign="top"
| '''Errors'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:xsd-report|$input as item()|element(report)}}<br /pre>{{Func|validate:xsd-report|( $input as item(), $schema as xs:string?|element(report)}}<br />{{Func|validate :xsd-report|$input as item= (), $schema as xs:string?, $features options as map(*)| := map { }) as element(report)}}</pre>
|- valign="top"
| '''Summary'''
|Validates the XML {{Code|$input}} document against a {{Code|$schema}}, using the processor-specific {{Code|$features}}, and returns warnings, errors and fatal errors as XML. See {{Function||validate:xsd}} for more information of the {{Code|$options}} parameter.
|- valign="top"
| '''Errors'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>validate:xsd-processor||() as xs:string}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|<pre>validate:xsd-version||() as xs:string}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:rng|$input as item(), $schema as item()|empty-sequence()}}<br/pre>{{Func|validate:rng|( $input as item(), $schema as item(), $compact as xs:boolean|? := map { }) as empty-sequence()}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:rng-info|$input as item(), $schema as item()|xs:string*}}<br/pre>{{Func|validate:rng-info|( $input as item(), $schema as item(), $compact as xs:boolean|? := map { }) as xs:string*}}</pre>
|- valign="top"
| '''Summary'''
{| width='100%'
|- valign="top"
| width='120' | '''SignaturesSignature'''|{{Func|validate:rng-report|$input as item(), $schema as xs:string|element(report)}}<br /pre>{{Func|validate:rng-report|( $input as item(), $schema as xs:string, $compact as xs:boolean|? := map { }) as element(report)}}</pre>
|- valign="top"
| '''Summary'''
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]: