JDK (Java Development Kit) Tutorials
Dr. Herong Yang, Version 5.00

DTD (Document Type Definition) - XML Validation

This chapter provides tutorial notes and example codes on DTD (Document Type Definition). Topics include writing an XML DTD validator using DOM and SAP interfaces; overriding error handler methods to print validation errors.

DOMValidator.java - XML DTD Validation with DOM

Testing DOM XML DTD Validator

SAXValidator.java - XML DTD Validation with SAX

Conclusion:

  • JDK supports XML DTD validation through both DOM and SAX interfaces.
  • It is very easy to override error handler methods to print XML validation errors with line numbers and detailed messages.

Notes and sample codes bellow are based on JDK/J2SDK 1.4.1_01.

Read my other book "Tutorial Notes on XML" on other XML related topics.

Dr. Herong Yang, updated in 2008
DTD (Document Type Definition) - XML Validation