[jdom-interest] XMLOutputter and Comments

Elliotte Rusty Harold elharo at metalab.unc.edu
Tue Jun 20 13:03:47 PDT 2000


I've revised XMLOutputter to not use PrintWriter and to throw more
IOExceptions. I'll submit that shortly.  I'd like to propose several
more API changes that make the API more consistent and more useful for
some edge cases. 

First, I'd like to output comments by adding this method:

protected void printComment(Comment comment, Writer out)  throws
IOException {}

This is more symmetrical with how other nodes are handled. It also makes
it very easy to write an outputter that strips comments by overriding
this method to do nothing. I thought of this when I wrote an outputter
that stripped everything except text content, and my comments showed up
anyway. The reason is because they're currently handled by invoking
getSerializedForm() in  printElement() and output() rather than
directly.

Next, I'd like to add a printEntity() method like this:

protected void printEntity(Entity entity, Writer out) throws IOException
{}

By overriding this method, subclasses could place entities in separate
files, though I wouldn't make this the default behavior. 

Next, I'd like to change the plural 

protected void printProcessingInstructions(List pis, Writer out) throws
IOException {}

to the singular

protected void printProcessingInstruction(ProcessingInstruction pi,
Writer out) throws IOException {}

Along with some other not particularly difficult changes to the other
methods, this would let the outputter maintain the order and location of
processing instructions in the document.

What do you think?

-- 
+-----------------------+------------------------+-------------------+
| Elliotte Rusty Harold | elharo at metalab.unc.edu | Writer/Programmer |
+-----------------------+------------------------+-------------------+ 
|               Java I/O (O'Reilly & Associates, 1999)               |
|            http://metalab.unc.edu/javafaq/books/javaio/            |
|   http://www.amazon.com/exec/obidos/ISBN=1565924851/cafeaulaitA/   |
+----------------------------------+---------------------------------+
|  Read Cafe au Lait for Java News:  http://metalab.unc.edu/javafaq/ | 
|  Read Cafe con Leche for XML News: http://metalab.unc.edu/xml/     |
+----------------------------------+---------------------------------+



More information about the jdom-interest mailing list