[jdom-interest] SAXBuilder enhancement request /2

Bradley S. Huffman hip at a.cs.okstate.edu
Fri Mar 29 21:18:34 PST 2002


Dennis Sosnoski writes:

> I'd personally recommend two options - one to discard character data 
> sequences consisting only of whitespace, the other to strip leading and 
> trailing whitespace from character data content. It could also be done 
> using a filter, as ERH suggests, though this might be a little more 
> complicated - for stripping trailing whitespace you'd need to make sure 
> you have the entire character data sequence available, rather than just 
> a portion.

FYI, in SAXHandler we have the entire sequence of characters between tags.

I think SAX's XMLFilter is too complicated for this application, so my I
suggest a simple CharacterHandler as follows:

    public interface CharacterHandler {

        /** Return String for Text node */
        public String text(char[] data);

        /** Return String for CDATA node */
        public String cdata(char[] data);
   }

and a setCharacterHandler(CharacterHandler) in SAXBuilder.

Another option would be to allow JDOMFactory to return null from the text and
cdata methods to indicate to SAXHandler there is nothing to add.

Brad



More information about the jdom-interest mailing list