[jdom-interest] BUG: XMLOutputter inserts extra empty lines
hal at idi.ntnu.no
Thu Dec 6 22:47:37 PST 2001
> ... would it be viable to create a "filter" structure whereby one can
> provide a list of adapters that are singularly focussed?
I've been toying with the same idea, a kind of output-analog to the Builder,
SAXBuilder and SAXParser structure that is used when reading, parsing and
building a document. The idea is to use the SAXReader (or SAXFilter)
interface to also perform output, and I believe there are SAXReaders that do
this already, i.e. receive SAX events and write out a new XML document
(Quote from first draft of SAX Filters, Chapter 8 of Processing XML with
Java at Cafe con Leche."I'm going to use David Megginson's public domain
com.megginson.sax.XMLWriter class. This class not only implements
ContentHandler. It's also an XMLFilter. "
This SAX event writer class would be driven by a SAXShredder (opposite of
Builder) wrapped by a Shredder. The SAXShredder would traverse the JDOM
document and call the appopriate handlers in the SAXReader/SAXFilter. This
structure could be used for other tasks, too, such as transforming and
searching for particular elements or text strings (this would require an
NodeFoundException, to return the found node).
> this would very likely be more expensive as it would require a traversal
> for each filter ... but this is the only downside i see at the moment.
Agreed, the structure is highly flexible, and instead of traversing for each
filter, they could be made to work in sequence for each node, by making a
filter that drives another set of filters. Such a filter is shown in the
book chapter I quoted from above.
More information about the jdom-interest