Database Reference
In-Depth Information
Performing explicit validation
You can perform explicit validation using the functions from the validate extension
module. This module has separate functions for all three parsers (JAXP, JAXV, and
Jing).
There are also generic validation functions that try to select the best parser for you,
based on the type of grammar document that you provide. We'll describe these
generic functions here; the functions for the specific parsing types are more or less
the same. For specifics, please refer to the online XQuery function documentation .
There are two generic validation functions:
validation:validate
This will validate your input document and return true or false depending on
the result.
validation:validate-report
This will validate your input document and return an XML fragment describing
the result. Use this if, for instance, you have to provide detailed feedback to the
end user about the validity of some input.
These functions will choose a parser based on the type of grammar document: if this
is a DTD or XML schema, the JAXP (Xerces) parser is used, otherwise Jing is used.
These functions do not produce the correct results for XML where
the root element is not in a namespace. In that case, use the specific
functions instead (e.g., validation:jing-report ).
Both functions have the following arguments:
$instance as item()
This is the input document to validate. You can specify either a URI (data type
xs:anyURI ), an element, or a document node.
$grammar as xs:anyURI
This argument is optional. It is used to determine the grammar document. Speci‐
fying the grammar in $grammar can be done in one of four ways:
• If you don't specify $grammar , the catalogs defined for implicit validation
(see “Specifying catalogs for implicit validation” on page 247 ) are used.
• If the $grammar URI ends with .dtd (DTD), .xsd (XML Schema), .rng
(RELAX NG), .rnc (RELAX NG Compact), .sch (Schematron), or .nvdl
(NVDL), it is assumed to reference a grammar document of that type.
Search WWH ::




Custom Search