An XML document can be categorized into two stages of compliance:
- Well-Formed XML: Conforms to basic XML syntax rules (tags closed, single root, quoted attributes).
- Valid XML: In addition to being well-formed, conforms to an external schema definition specifying allowed tag names, ordering, and data types.
XSD (XML Schema Definition)
W3C XML Schema (XSD) is written in XML itself. It allows developers to enforce strong typing (e.g. xs:integer, xs:date), value restrictions (regex patterns, min/max lengths), and complex hierarchies.