Components All New MacOS Windows Linux iOS
Examples Mac & Win Server Client Guides Statistic FMM Blog Deprecated Old

Saxon.Validate

Validates a XML against the given schema.

Component Version macOS Windows Linux Server iOS SDK
Saxon 15.0 ✅ Yes ✅ Yes ✅ Yes ✅ Yes ❌ No
MBS( "Saxon.Validate"; XML; Schema { ; lax; xsdversion } )   More

Parameters

Parameter Description Example Flags
XML The XML to work on.
Schema The schema to use for validation.
lax Whether to use lax rules. 1 Optional
xsdversion The XSD Version to use. "1.1" Optional

Result

Returns OK or error.

Description

Validates a XML against the given schema.
Validate refers to the process of checking whether an XML document conforms to a defined structure and rules specified in a schema (like XSD) or DTD. This ensures the XML data is both well-formed (syntactically correct) and valid (logically structured as expected).

Set the current working directory with Saxon.SetCWD function, so the function can find relative files.
Requires the Saxon-EEV license.

The validation mode may be either strict or lax.
The default is strict; the lax parameter may be called to indicate that lax validation is required. With strict validation, validation fails if no element declaration can be located for the outermost element. With lax validation, the absence of an element declaration results in the content being considered valid.

Examples

Try validation:

MBS( "Saxon.Validate"; "<request><a>1</a><b>2</b></request>"; "<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' ¶
elementFormDefault='qualified' ¶
attributeFormDefault='unqualified'><xs:element ¶
name='request'><xs:complexType><xs:sequence><xs:element name='a' ¶
type='xs:string'/><xs:element name='b' ¶
type='xs:string'/></xs:sequence><xs:assert test='count(child::node()) = ¶
2'/></xs:complexType></xs:element></xs:schema>" )

See also

Example Databases

Blog Entries

This function checks for a license.

Created 27th December 2024, last changed 12nd June 2025


Saxon.SetProperty - Saxon.ValidationReport