[jdom-interest] XMLOutputter and Comments

Brett McLaughlin brett.mclaughlin at lutris.com
Tue Jun 20 10:48:59 PDT 2000


Elliotte Rusty Harold wrote:
> 
> I've revised XMLOutputter to not use PrintWriter and to throw more
> IOExceptions. I'll submit that shortly.  

+1

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 {}

+1

> 
> 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
> {}

+1

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

Good idea.

> 
> 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 {}

+1

> 
> 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?

I think you're onto some good ideas - I'm all for all of them. It's also
nice because the external API stays consistent ;-)

-Brett

> 
> --
> +-----------------------+------------------------+-------------------+
> | 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/     |
> +----------------------------------+---------------------------------+
> _______________________________________________
> To control your jdom-interest membership:
> http://lists.denveronline.net/mailman/options/jdom-interest/youraddr@yourhost.com

-- 
Brett McLaughlin, Enhydra Strategist
Lutris Technologies, Inc. 
1200 Pacific Avenue, Suite 300 
Santa Cruz, CA 95060 USA 
http://www.lutris.com
http://www.enhydra.org



More information about the jdom-interest mailing list