| |
How is the document validated?
The DTD describes a model of the structure of the content of an XML document. This model says what elements must be present, which ones are optional, what their attributes are, and how they can be structured with relation to each other. While HTML has only one DTD, XML allows you to create your own DTDs for your applications. This gives you complete control over the process of checking the content and structure of the XML documents created for that application. This checking process is called validation.
A valid XML document is not just syntactically correct, but has an internal structure that complies with the model structure that is declared in the DTD or Schema. So, a valid XML document is a well-formed XML document that also conforms to the declarations, structures, and other rules defined in the document's respective DTD or schema.
Well-formed XML documents meet the W3C's specific grammatical, logical, and structural rules outlined in the W3C's XML 1.0 Recommendation. The W3C has judged that a fatal error has occurred if and when a confirming XML processor detects that an XML document violates the recommended well-formed constraints.
- A valid XML document is a well-formed XML document that also conforms to the rules defined in a document type definitions (DTD), or an XML schema.
- A document, that is well-formed, however, may not be valid.
- A well-formed XML document has to follow several rules such as :
- Only one root element.
- Proper Nesting.
- Well-formed entities.
- Validation is particularly important when the destination of an XML document needs to know that the data being received is according to the standard structure it expects.
- If there is a reference to a DTD or schema in an XML document, any program that reads, understands, and helps to do something useful with an XML document can validate the document or choose to ignore it.
- Such programs, typically called parsers, may or may not have the capacity to validate an XML document.
If parsers can validate, they are called Validating Parsers and if they cannot, they are called Non-validating Parsers.
XML Validator
You can syntax-check your XML files by just pasting your XML document into the text field provided in the URL below :
| URL |
| http://www.stg.brown.edu/service/xmlvalid/ |
and hit the validate button. If the document is too large to be conveniently pasted into the text field, enter its filename into the local file field. You may also validate an arbitrary XML document on the Web by typing its URI into the URI field.
| |
| Summary |
| |
In this chapter you have learnt:
- About DTD and its importance.
- Types of DTDs associated with an XML document.
- About XML schema and how are they different from XML DTDs
- Importance of a valid document
- Role of an XML validator.
|
| |
| |
| Review Questions |
| |
Fill in the Blanks
- ________ and ________ are models of the logical structure of the content of an XML document.
- The DTD name is similar to the ________ element name of XML document.
- _______ contains only one DTD.
- _______ DTDs are included inside XML source file.
- Two types of parsers are ________ and________.
Solutions
- DTD and Schema
- root
- HTML
- Internal
- Validating parsers and Non validating parsers
True or False
- The DTD name should always match the root element name except for external DTDs.
- For internal DTD, the standalone parameter in the XML version statement is set to "no".
- External DTD can be shared by more than one XML documents.
- Schema has non-XML syntax.
- A well-formed XML document is always a valid XML document.
Solutions
- False
- False
- True
- False
- False
|
| |
| |
| What's Next |
The next chapter will acquaint you with the basic concept of various browsers and their support for XML. The chapter will further elucidate how an XML file would be viewed in a browser.
Hop over to the next chapter to get a close-up of browsers that support XML. |
|
| |
|
| |
|