Saturday 17 December 2011

What is XML validation and what is the output?

According to W3C , a valid XML document is a well formed XML document, which also valid in that it conforms to the rules of a Document Type Definition (DTD). A well formed document follows the basic syntactic rules of XML, which are the same for all XML documents. A valid document respects the rules dictated by a particular DTD or XML schema according to the application specific choices. So basically a valid XML document must:

  • be well formed
  • have a DOCTYPE declaration
  • comply with a defined logical structure indicated by the DTD that the DOCTYPE declaration says that it is
For example:

<?xml version="1.0" ?>
<!DOCTYPE note SYSTEM "Note.dtd">
<note>
<to>Tove</to>
<from>Jani</Ffrom>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>


The DOCTYPE declaration in the example above, is a reference to an external DTD file.

Due to the W3C XML specification, a program should stop processing an XML document if it finds an error but allows for some flexibility in regarding the validation. The output of an XML validator depends on the implementation. It would most likely consist of a list of errors encountered.

To help you check the syntax of XML files, W3C has created an XML validator to syntax-check XML.

No comments:

Post a Comment