XML validation

XML validation is the process of checking a document written in XML (eXtensible Markup Language) to confirm that it is both well-formed and also "valid" in that it follows a defined structure. A well-formed document follows the basic syntactic rules of XML, which are the same for all XML documents.[1] A valid document also respects the rules dictated by a particular DTD or XML schema.[2] Automated tools – validators – can perform well-formedness tests and many other validation tests, but not those that require human judgement, such as correct application of a schema to a data set.

## Contents

* 1 Well-formedness versus validity
* 2 Standards
* 3 Tools
* 4 References

## Well-formedness versus validity

An XML document must be well-formed before it can be validated. A well-formed document conforms to the syntax rules defined by the XML specification, including proper nesting of elements, matching start and end tags, and correct attribute syntax.[1]

Validation is a separate process in which a well-formed document is evaluated against a schema language such as a Document Type Definition (DTD), XML Schema, RELAX NG, or Schematron to determine whether it conforms to the required document structure and constraints.[2]

A document may therefore be well-formed but not valid if it satisfies the syntax requirements of XML while failing to meet the constraints defined by its associated schema.

## Standards

Several schema languages and validation standards have been developed for XML.[2]

* Document Type Definition (DTD), the original schema language inherited from SGML.
* XML Schema (XSD), the W3C recommendation for defining XML document structure and datatypes.
* RELAX NG, an ISO standard schema language for XML.
* Schematron, a rule-based validation language for expressing constraints that cannot easily be represented in grammar-based schema languages.
* OASIS CAM, a specification providing contextual validation of XML content and structure.

## Tools

* xmllint is a command line XML tool that can perform XML validation. It can be found in UNIX / Linux environments.
* XML toolkit. The XML C parser and toolkit of Gnome – libxml includes xmllint.
* XML Validator Online – Validate XML data.
* XML Schema Validator – Validate XML files against an XML Schema.

## References

1. ↑ 1.0 1.1 "Well-Formed XML Documents". Extensible Markup Language (XML) 1.1. W3C. 2004. http://www.w3.org/TR/2004/REC-xml11-20040204/#sec-well-formed.
2. ↑ 2.0 2.1 2.2 "Constraints and Validation Rules". XML Schema Part 1: Structures Second Edition. W3C. 2004. http://www.w3.org/TR/xmlschema-1/#concepts-schemaConstraints.

Articles discussing XML validation

* DEVX (March 2009) – Taking XML Validation to the Next Level: Introducing CAM

0.00

(0 votes)

Original source: https://en.wikipedia.org/wiki/XML validation. Read more

|

Retrieved from "https://handwiki.org/wiki/index.php?title=XML_validation&oldid=4569397"