|
XML with correct syntax is Well Formed XML.
XML validated against a DTD is 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 version="1.0"?>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
"Valid" XML documents
A "Valid" XML document also conforms to a DTD.
A "Valid" XML document is a "Well Formed" XML document, which
also conforms to the rules of a Document Type Definition (DTD):
<?xml version="1.0"?>
<!DOCTYPE note SYSTEM "InternalNote.dtd">
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>
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
XSchema is an XML based alternative to DTD.
W3C supports an alternative to DTD called XML Schema.
Errors in XML documents will stop the XML program.
The W3C XML specification states that a program should not
continue to process an XML document if it finds a validation
error. The reason is that XML software should be easy to write,
and that all XML documents should be compatible.
With HTML it was possible to create documents with lots of
errors (like when you forget an end tag). One of the main
reasons that HTML browsers are so big and incompatible, is that
they have their own ways to figure out what a document should
look like when they encounter an HTML error.
With XML this should not be possible.
|