XML Validation

XML validated against a DTD or a Schema is a Valid XML.

XML Validation

XML Validation

     

XML with correct syntax is Well Formed XML.

XML validated against a DTD or a Schema  is a Valid XML.

Well Formed XML Documents

A "Well Formed" XML document has correct XML syntax.

A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous chapters:

  • XML documents must have a root element
  • XML elements must have a closing tag
  • XML tags are case sensitive
  • XML elements must be properly nested
  • XML attribute values must always be quoted

 

<?xml version="1.0" encoding="ISO-8859-1"?>
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u  tonight</Body>
</E-mail>

Valid XML Documents:

A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) or a XML Schema .

The following xml document is validated against a DTD , notice the highlighted text.

<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE e-mail SYSTEM "InternalE-mail.dtd">
<E-mail>
<To>Rohan</To>
<From>Amit</From>
<Subject>Surprise....</Subject>
<Body>Be ready for a cruise...i will catch u  tonight</Body>
</E-mail

XML DTD

A DTD defines the legal elements of an XML document. The purpose of a DTD is to define the legal building blocks of an XML document. It defines the document structure with a list of legal elements.

XML Schema 

XML Schema is an XML based alternative to DTD .W3C supports an alternative to DTD called XML Schema.