[jdom-interest] XMLOutputter observations

Rick Beton richard.beton at dsl.pipex.com
Thu Feb 26 14:28:11 PST 2004

Hi All,

I'm new on the list so forgive me if this repeats things others have 
already said. 

I wanted to write some XHTML and SVG documents from Java, so I started 
writing an XMLWriter class to ensure the syntax is well-formed and 
valid.  Then I thought I'd check out other possibilities before I'd gone 
too far on a home grown solution.  JDOM offers what appears (in my 
limited knowledge) to be a well-matched solution to what I need.

So I downloaded the source code via CVS and started looking through to 
see what it could do for me.  Here are a few first-impression 
detail-code-review type of observations, which may be useful or not.  (I 
don't claim to have done any sort of thorough code review, just a first 
glance. Generally, it appears a lot of care has gone into the coding, 
which inspires a good level of confidence.).

Re: org.jdom.output.XMLOutputter rev 1.105

1. lines 59...: imports with * should be expanded (to eliminate 

2. skipTrialingWhite (line 1220) - spelling should be skipTrailingWhite
    - this method is private so it's not very important

3. outputString (lines 524...) - these methods are perhaps in the wrong 
class. Although a clever convenience, they rather fatten the class with 
something that could have been separate (e.g. as a helper class or a 
derived class).

4. I am uneasy that the output(Document doc, OutputStream out) method, 
which writes a whole document in one go, sits alongside a suite of other 
output methods that write a document part by part. These seem to me to 
be different ways of doing the same thing; perhaps therefore they should 
be done by different classes (?).

5. Eclipse points out some other redundant imports:
XMLOutputter only needs
import java.io.BufferedOutputStream;
import java.io.BufferedWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.StringWriter;
import java.io.Writer;
import java.util.List;
import org.jdom.Attribute;
import org.jdom.CDATA;
import org.jdom.Comment;
import org.jdom.DocType;
import org.jdom.Document;
import org.jdom.Element;
import org.jdom.EntityRef;
import org.jdom.Namespace;
import org.jdom.ProcessingInstruction;
import org.jdom.Text;

DefaultJDOMFactory:  only needs
import java.util.Map;

JDOMFactory: only needs
import java.util.Map;

ElementFilter only needs:
import java.io.IOException;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import org.jdom.Element;
import org.jdom.Namespace;

That's enough for now. Enjoy!
Rick :-)

-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/x-pkcs7-signature
Size: 3455 bytes
Desc: S/MIME Cryptographic Signature
Url : http://jdom.org/pipermail/jdom-interest/attachments/20040226/d93f9704/smime.bin

More information about the jdom-interest mailing list