Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

From the author of

Validating Documents

Whether developing new XML DTDs or schemas, creating new XML documents, or verifying that a program is generating correct XML output, being able to quickly validate an XML document is an important task. Every XML parser must at least be able to determine whether a particular document is well-formed. More sophisticated parsers can verify that the document's structure matches the formal description in a DTD or schema. The following sections discuss various tools that can be used to validate XML documents.

Web Browsers

After the initial breakneck race between Netscape and Internet Explorer for Internet domination, the rate of introduction of new browser features has slowed considerably. Microsoft has included some form of XML support in IE since version 5.0, although it didn't fully support the XSLT recommendation until version 5.5. The release of Netscape as an Open Source product (Mozilla) did not appreciably accelerate the introduction of XML support. The most recent versions of Netscape and Mozilla do include support for displaying XML documents using CSS2 (no XSLT support is included).

The incorporation of XML parsing and validation into IE means that practically any Windows computer can be used to write and validate XML documents. To quickly validate a new XML document, simply display it using IE. Any well-formedness or validity errors will be flagged by the browser.

Standalone Validators

In many applications, it's desirable to independently check the well-formedness and validity of an XML document. Most XML parser packages provide simple standalone tools for parsing and validating documents from the operating-system command line. These tools always check for well-formedness, and they can also be configured to validate against the document's DTD and/or an associated schema file.

Web-Based Validation Services

Some web sites provide tools for validating XML documents on the World Wide Web. Some of them require that the target document be hosted on another web server, whereas others allow the user to upload a copy of the document. If you intend to perform a large number of validations, this type of tool can become cumbersome quickly. However, if you need to validate a document quickly and don't have a standalone tool or XML-enabled web browser handy, these tools can be a useful alternative. These are two online validators available at the time of this writing:

  • + Share This
  • 🔖 Save To Your Account