Class ContentPrinter

java.lang.Object
eu.bandm.tools.util.xml.DefaultContentHandler
eu.bandm.tools.util.xml.ContentPrinter
All Implemented Interfaces:
ContentHandler, LexicalHandler

public class ContentPrinter extends DefaultContentHandler
Converts SAX events into textual representation, not supporting name spaces. Supports a subset of ContentHandler and LexicalHandler.
Can be parametrized w.r.t
  • target of output (normally a PrintWriter or sim.
  • encoding
  • format of output (indenting, compressed, debug only)
  • whether to include doctype and/or xmltype declaration
Character data is transformed, using the standard character entities "quot" "amp" "lt" "gt". ("apos" should not be used, for old html handlers.)
CData sections and disable output escaping are not supported.

The encoding name which appears in the XML output must have a form like "UTF-8", and "SHOULD be understood in a case-insensitive way." ([XML1.0], setion 4.3.3).
Similarly, the API doc for Charset says "Charset names are not case sensitive". In this module all instances of the Charset class are replaced by their "canonical name". To detect cases of UnsupportedEncodingException are left to the java runtime classes.

CHECK NOETIG !?!?!? Korrekte übersetzung nicht automatisch bei PrintWriter !?!?

Surrogate pairs are translated to Numeric character references, BUT ONLY IN CDATA/PCDATA, not in Element names, attribute names, pi targets, etc.
FIXME: currently PrintWriter is only needed for "println()".
This COULD be replaced by a Writer and "append( System property "line.separator", PLUS an additional method to alter this explicitly!