Valider XML against XSD schema
XSD (XML Schéma Définition) defines le structure, element types, et constraints de un XML document. Valider documents against schemas en ensure correctness.
- 1
XSD defines: allowed elements and attributes, their types (string, integer, date, boolean), occurrence constraints (minOccurs, maxOccurs), nesting rules, and custom types (simpleType, complexType). Validation checks that an XML document conforms to the schema — catching structural errors, missing required fields, and type mismatches.
- 2 Formateur XML →
Formater the XML document to verify basic well-formedness (all tags closed, proper nesting, valid characters). Well-formed XML is the minimum requirement — schema validation checks conformance to a specific structure.
- 3 Validateur JSON →
For JSON alternatives, use JSON Schema validation. Convert the XSD to a JSON Schema (or write one directly) and validate JSON converted from XML. JSON Schema is simpler than XSD and more commonly used in modern APIs.
- 4
XSD validation catches: missing required elements, elements in wrong order (if sequence is specified), invalid types (string where integer expected), too many or too few occurrences, invalid attribute values. Use it for B2B data exchange where strict contracts are required.
Questions fréquentes
- XSD vs DTD vs RelaxNG?
- XSD (W3C) is the most widely supported — rich type system, namespaces. DTD is older and simpler but limited (no namespaces, limited types). RelaxNG is more expressive but less adopted. Use XSD for maximum compatibility.
- Should I use XSD or JSON Schema?
- For XML systems, use XSD. For JSON APIs, use JSON Schema. If migrating from XML to JSON, convert XSD to JSON Schema as a starting point, but review — the mapping is not always direct. JSON Schema is simpler and more web-friendly.