Skip to main content

XML/XSD matching

The value must be a valid XML matching an XSD.

Parameter table

paramunitrequireddescription
keyyesThe key of the XML value to validate.
schemayesThe XSD schema to validate against.

How to setup

This rule checks whether the XML value associated with the specified (key) matches the specified XSD (schema). The Schema is an XML document that describes the structure and format of the XML data. For more information about XSD, check out the W3Schools tutorial.

If the XML value does not match the schema, the rule will fail.

Creator tips

XSD stands for XML Schema Definition. It is a way to describe and validate the structure and content of XML documents. XSD uses a syntax to define the elements, attributes, and data types allowed in an XML document. It helps ensure that XML documents conform to a specific structure, making it easier to exchange data between different systems. So, this rule can be used to validate your XML data against an XSD schema.

To build an XML that matches an XSD schema, you have to follow the structure of the XSD schema and the data types of the elements. For a quick tutorial about XML, check out the W3Schools tutorial. You can also refer to the examples.

Examples

valuevalidschemadescription
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="note">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="to" type="xsd:string"/>
<xsd:element name="from" type="xsd:string"/>
<xsd:element name="heading" type="xsd:string"/>
<xsd:element name="body" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The XML value matches the XSD schema.
<?xml version="1.0" encoding="UTF-8"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
</note>
<?xml version="1.0" encoding="UTF-8"?>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:element name="note">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="to" type="xsd:string"/>
<xsd:element name="from" type="xsd:string"/>
<xsd:element name="heading" type="xsd:string"/>
<xsd:element name="body" type="xsd:string"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
The XML value does not match the XSD schema.