11.2. Message Validation
Here is a sample that depicts message validation.
Message Content:
<MyBook xmlns="example"> <Chapter1/> <Chapter2/> </MyBook>
This is the associated XML Schema definition:
<?xml version="1.0" encoding="UTF-8"?> <schema xmlns="http://www.w3.org/2001/XMLSchema" targetNamespace="example" xmlns:orders="example"> <element name="MyBook" type="example:MyBook"/> <complexType name="MyBook"> <sequence> <element name="Chapter1" type="string"/> </sequence> </complexType> </schema>
The XML content is still well-formed, but it has a
Chapter2
element that is not declared as the child of MyBook
element in the XML schema. Hence the content cannot be validated against the schema.