Validating an XML File against a DTD Document Type
This section describes different ways to validate XML files against DTD document types: using standalone XML validation tools, using on-line XML validators, and writing your own XML validation programs.
So far we learned how to use DTD statements to define a document type for an XML file.
We also learned how to specify a document type defined by DTD statements to an XML file.
Now let's see how we can validate an XML file against the specified document type.
In general, Web browsers like IE and Firefox can be used to browse XML files.
But they can not be used to validate XML files. So we have to look for other ways to perform XML DTD validation:
1. Using XML DTD validation tools:
- XML Spy is an IDE (Integrated Development Environment) for XML documents produced by Altova.
XML Spy can be used to validate XML files against DTD document types. But it is not free to use.
- XMLStarlet is an open source command line tool to manipulate XML files.
XMLStarlet can be used to validate XML files against DTD document types. And it is free to use.
See http://xmlstar.sourceforge.net/ for more information.
2. Using XML DTD on-line validators:
- W3C Markup Validation Service is designed to validate Web documents. But it can also be used
to validate XML documents against DTD document types.
Go to http://validator.w3.org/#validate_by_input to try it out.
- Validome is a non-commercial XML validation software. They offer an on-line XML validator that
supports DTD document types.
Go to http://www.validome.org/xml/ to try it out.
3. Write your own XML validators with XML DTD validation API:
- JDK 1.4 and newer versions supports XML DTD validation API.
See the DTD validation chapter for example Java programs.
Last update: 2014.
Table of Contents
About This Book
Introduction of XML (eXtensible Markup Language)
XML File Syntax
XML File Browsers
DOM (Document Object Model) Programming Interface
SAX (Simple API for XML) Programming Interface
►DTD (Document Type Definition) Introduction
What Is DTD (Document Type Definition)?
XML Files with Embedded DTD Statements
XML Files with Linked External DTD Files
►Validating an XML File against a DTD Document Type
Syntaxes of DTD Statements
Validating an XML Document against the Specified DTD Document Type
XSD (XML Schema Definition) Introduction
Syntaxes of XSD Statements
Validating XML Documents Against Specified XML Schemas
XSL (Extensible Stylesheet Language) Introduction
XSLT (XSL Transformations) Introduction
Java Implementation of XSLT
XPath (XML Path) Language
XSLT Elements as Programming Statements
Control and Generate XML Element in the Result
XML Notepad - XML Editor
XML Tools Plugin for Notepad++
XML 1.1 Changes and Parsing Examples
Full Version in PDF/EPUB