Announcement: XMLWriter and XMLNorm

David Megginson david at megginson.com
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

  com.megginson.sax.XMLWriter
  com.megginson.sax.XMLNorm

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
                            documents.
************************************************************************

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 http://home.sprynet.com/~dmeggins/texts/darkness/darkness.xml

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

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


------------------------------------------------------------------------
David Megginson, david at megginson.com
21 July 1999


All the best,


David

-- 
David Megginson                 david at megginson.com
           http://www.megginson.com/

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





More information about the Xml-dev mailing list