This section describes assertion introduced in XSD 1.1. It you to specify any validation rules represented as XPath expressions on XML documents.
What Is an Assertion?
An assertion is a new feature introduced in XSD 1.1 that allows you to specify
any validation rules represented as XPath expressions on XML documents.
Here is the syntax on how an assertion rule should be defined in XSD schema:
Assertion should be applied to user defined datatype declared as "complexType" or "simpleType".
If an assertion is applied to a "complexType" datatype, assertion rules are declared as "assert" statements
and placed inside the "complexType" statement at the end.
If an assertion is applied to a "simpleType" datatype, assertion rules are declared as "assertion" statements
and placed inside the "restriction" statement at the end.
"assert[@test]" is required to provide an XPath expression,
which must be evaluated to "true" for the XML document to be valid.
For example, the following assertion applies to a "complexType" datatype.
It specifies that the "min" attribute value must be less or equal to the "max" attribute value: