XSD
XSD (XML Schema Definition) is the W3C-standard language for defining XML document structure, describing elements, attributes, and type constraints in XML syntax.
Purpose
To provide strict validation of XML documents, defining element hierarchy, types, and constraints.
Mechanism
It declares in XML syntax: element defines elements, complexType defines structures, and simpleType defines constraints (e.g., enumeration, regex). It supports namespaces, type inheritance, and substitution groups. Validators (e.g., xmllint) check XML documents against it.
Use cases
- SOAP WSDL type definitions
- Enterprise data exchange schemas
- Government/financial XML standards
- Document validation
Examples
- Input
<xs:element name="age" type="xs:int"/>OutputThe age element must be an integerA type constraint
Common errors
- An overly complex schema becomes hard to maintain
- Generate it with tools or consider JSON Schema
Related terms
XML
XML (Extensible Markup Language) is the W3C-standard markup language describing data with a tag tree, supporting namespaces, schema validation, and style transformation. GLOSSARY
DTD
A DTD (Document Type Definition) is the structure-definition mechanism of XML 1.0; it is simpler than XSD but limited, and is written in a special (non-XML) syntax. GLOSSARY
JSON Schema
JSON Schema is a vocabulary for describing the structure of JSON documents, defining types, constraints, and validation rules; it is the schema standard for JSON. GLOSSARY