[jdom-interest] XMLOutputter

Alex Chaffee guru at edamame.stinky.com
Fri Aug 4 06:56:17 PDT 2000


On Sun, Jul 30, 2000 at 03:19:04PM -0500, Brett McLaughlin wrote:
>   The problem is that documents created in memory are the exact opposite
> - they need the indentation and new lines that XMLOutputter uses. So it
> (XMLOutputter) really needs different "defaults" based on the use-case.
> >From scratch docs needs the older version with indents and newlines,
> existing docs need no formatting. 

Replace "defaults" with "options", and provide constructors that allow
users to specify those options.  How many are we talking about here?
Whitespace, indenting, end-of-line character (or lack thereof),
showing comments, showing PIs, expanding entities.  Any others?  We
can put the commonly-controversial ones in constructors, and save the
rest for set methods.

To spell it out:

public class XMLOutputter {

    /**
     * uses some set of options to be dickered over ad infinitum later
     * -- my vote is for show whitespace / no indentation / no line
     * ending char / show all / don't expand entities
     **/
    public XMLOutputter();

    public XMLOutputter(boolean showWhitespace,  
			String indentString	// null = no indent
			);


    public void setShowWhitespace(boolean x);

    public void setIndentString(String x);

    public void setLineEnding(String x);

    public void setShowComments(boolean x);

    public void setShowProcessingInstructions(boolean x);

    public void setExpandEntities(boolean x);

    // then follow all the actual output methods

}




-- 
Alex Chaffee                       mailto:alex at jguru.com
jGuru - Java News and FAQs         http://www.jguru.com/alex/
Creator of Gamelan                 http://www.gamelan.com/
Founder of Purple Technology       http://www.purpletech.com/
Curator of Stinky Art Collective   http://www.stinky.com/



More information about the jdom-interest mailing list