Cover Pages Logo SEARCH
Advanced Search
ABOUT
Site Map
CP RSS Channel
Contact Us
Sponsoring CP
About Our Sponsors

NEWS
Cover Stories
Articles & Papers
Press Releases

CORE STANDARDS
XML
SGML
Schemas
XSL/XSLT/XPath
XLink
XML Query
CSS
SVG

TECHNOLOGY REPORTS
XML Applications
General Apps
Government Apps
Academic Apps

EVENTS
LIBRARY
Introductions
FAQs
Bibliography
Technology and Society
Semantics
Tech Topics
Software
Related Standards
Historic

XMLWriter and XMLNorm - Java Classes


Date:     Wed, 21 Jul 1999 21:48:27 -0400 (EDT)
From:     David Megginson <david@megginson.com>
To:       XML Developers' List <xml-dev@ic.ac.uk>
Subject:  Announcement: XMLWriter and XMLNorm

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

See: http://www.megginson.com/Software/xmlwriter-19990721.zip

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@megginson.com
21 July 1999

All the best,

David

David Megginson                 david@megginson.com
           http://www.megginson.com/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@ic.ac.uk Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/ and on CD-ROM/ISBN 981-02-3594-1


Prepared by Robin Cover for the The SGML/XML Web Page archive.


Globe Image

Document URL: http://xml.coverpages.org/megginsonJavaCl19990721.html