Saxon.Validate
--------------

Validates a XML against the given schema.

| Component | Version | macOS | Windows | Linux | Server | iOS SDK |
|---|---|---|---|---|---|---|
| [Saxon](component_Saxon.md) | [15.0](newinversion150.md) | ✅ Yes | ✅ Yes | ✅ Yes | ✅ Yes | ❌ No |

MBS( "Saxon.Validate"; XML; Schema { ; lax; xsdversion } ) 

**MBS**( **"Saxon.Validate";** /\* Validates a XML against the given schema. \*/  
**$XML**; /\* The XML to work on. \*/   
**$Schema**; /\* The schema to use for validation. \*/   
**$lax**; /\* Optional; Whether to use lax rules.e.g. 1 \*/   
**$xsdversion**) /\* Optional; The XSD Version to use.e.g. "1.1" \*/ 

### 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"; "&lt;request&gt;&lt;a&gt;1&lt;/a&gt;&lt;b&gt;2&lt;/b&gt;&lt;/request&gt;"; "&lt;xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema' ¶  
elementFormDefault='qualified' ¶  
attributeFormDefault='unqualified'&gt;&lt;xs:element ¶  
name='request'&gt;&lt;xs:complexType&gt;&lt;xs:sequence&gt;&lt;xs:element name='a' ¶  
type='xs:string'/&gt;&lt;xs:element name='b' ¶  
type='xs:string'/&gt;&lt;/xs:sequence&gt;&lt;xs:assert test='count(child::node ()) = ¶  
2'/&gt;&lt;/xs:complexType&gt;&lt;/xs:element&gt;&lt;/xs:schema&gt;" )  
### See also

- [Saxon.ValidationReport](SaxonValidationReport.md)
- [XML.Validate](XMLValidate.md)
- [XML.ValidateFile](XMLValidateFile.md)

### Example Databases

- [DynaPDF/ZUGFeRD and Facture-X/ZUGFeRD Validation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/DynaPDF/ZUGFeRD%20and%20Facture-X/ZUGFeRD%20Validation.shtml#6ScriptAnchor_)
- [Saxon/Saxon Validate](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Saxon/Saxon%20Validate.shtml#2ScriptAnchor_)
- [Saxon/Saxon ZUGFeRD Validation](https://www.mbsplugins.eu/MBS-FileMaker-Plugin-Examples/Saxon/Saxon%20ZUGFeRD%20Validation.shtml#6ScriptAnchor_)

### Blog Entries

- [Validate electronic invoices with Saxon](https://www.mbsplugins.de/archive/2026-03-20/Validate_electronic_invoices_w/monkeybreadsoftware_blog_filemaker)
- [Electronic invoices in FileMaker](https://www.mbsplugins.de/archive/2025-03-06/Electronic_invoices_in_FileMak/monkeybreadsoftware_blog_filemaker)
- [Elektronische Rechnungen in FileMaker](https://www.mbsplugins.de/archive/2025-03-04/Elektronische_Rechnungen_in_Fi/monkeybreadsoftware_blog_filemaker)
- [Validate electronic invoices with Saxon](https://www.mbsplugins.de/archive/2025-02-18/Validate_electronic_invoices_w/monkeybreadsoftware_blog_filemaker)

This function checks for a license.

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

  
[Saxon.SetProperty](SaxonSetProperty.md) - [Saxon.ValidationReport](SaxonValidationReport.md)

[HTML Version](SaxonValidate.shtml)