 | Level: Introductory Nicholas Chase (nicholas@nicholaschase.com), Author, Studio B
27 Aug 2003 In the creation of a database, a data model and integrity constraints can create certainty in the structure and content of the data. But how do you enforce that kind of control when your data is just text in hand-editable files? Fortunately, validating files and documents can make sure that data fits constraints. In this tutorial, you will learn what validation is and how to check a document against a Document Type Definition (DTD) or XML Schema document. Prerequisites
You should be familiar with the basic concepts of XML, and have a basic familiarity with XML Namespaces. While this tutorial demonstrates validation using the Java language from the command line, experience with Java technology is not required to gain a thorough understanding.
System requirements
You will need JavaScript enabled on your browser. This tutorial will help you understand the topic even if you read the examples rather than trying them out. If you do want to try the examples as you go through this tutorial, make sure you have the following tools installed and working correctly:
- A text editor: XML files, DTDs, and XML Schema documents are simply text. To create and read them, a text editor is all you need.
- You can manipulate and validate XML in any language where a validating parser is available. The bulk of the tutorial deals with the creation of documents, but you will also see how to build an application that uses a validating parser. XML support has been built into the latest version of Java (available at http://java.sun.com/j2se/1.4.2/download.html), so you won't need to install any separate classes. (If you're using an earlier version, such as Java 1.3.x, you'll also need an XML parser such as the Apache project's Xerces-Java (available at http://xml.apache.org/xerces2-j/index.html), or Sun's Java API for XML Parsing (JAXP), part of the Java Web Services Developer Pack (available at http://java.sun.com/webservices/downloads/webservicespack.html).
If you have a different set of tools installed, you can use them instead. Just check the documentation for instructions on turning on validation. You can download C++ and Perl implementations of Xerces from the Apache Project at http://xml.apache.org.
Duration
Under one hour
Formats html, pdf
|  | |  |