Announcement: XMLWriter and XMLNorm

David Megginson david at
Thu Jul 22 03:46:59 BST 1999

Since I need them for several projects, I've created a couple of
smallish Java classes.  One is a DocumentHandler and DTDHandler that
writes an XML document back out to a Java Writer (like James Clark's
XMLTest, only much more configurable), and one is an application for
normalizing XML documents.  The classes are


Since it's short, here's the README itself:

com.megginson.sax.XMLWriter - a class for writing XML documents

This distribution contains a simple class,
com.megginson.sax.XMLWriter, which writes an XML document based
(mostly) on SAX events.  The writer implements the SAX 1.0
DocumentHandler and DTDHandler interfaces, and is highly configurable;
using flags, the application can specify any of the following actions:

- escape non-ASCII characters as character references
- add newlines in tags to improve readability
- include a simple DOCTYPE declaration, with any notation and
  unparsed entity declarations
- omit the XML declaration
- display attributes in random, unsorted order (for efficiency)
- attempt level-3 HTML browser compatibility, by killing the XML
  declaration, DOCTYPE declaration, and processing instructions, and
  adding a space before the closing delimiter of empty element tags

The output goes to a Writer provided by the application, and can use
any character encoding supported by the Java installation.

com.megginson.sax.XMLNorm - an application for normalizing XML

This distribution also contains an application,
com.megginson.sax.XMLNorm, that produces a normalized version of an
XML document, like James Clark's XMLTest class.  The usage is

  java com.megginson.sax.XMLNorm [opts] <file-or-uri>

The following options are available:

  -a: escape non-ASCII characters
  -d: include DOCTYPE declaration
  -h: display this help
  -n: add newlines in tags for readability
  -x: don't include the XML declaration
  -u: unsorted attributes (random order)
  -3: level-3 HTML browser compatibility kludges
  -o <file>: print output to the specified file
  -e <encoding>: use the specified output encoding

If you have a network connection, you can try the following:

  java com.megginson.sax.XMLNorm

(You can also try for other, shorter XML documents.)

By default, this application attempts to use Microstar's free AElfred
parser (, but you can use the
org.xml.sax.parser to point it to any other SAX-conformant parser.

David Megginson, david at
21 July 1999

All the best,


David Megginson                 david at

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev at
Archived as: and on CD-ROM/ISBN 981-02-3594-1
To (un)subscribe, mailto:majordomo at the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo at the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa at

More information about the Xml-dev mailing list