Thanks a lot. I'll start learning XSLT as well.
About what I have done, I used the decorator pattern and created a
decorator wrapping around my base handler. This will buffer the text
received in characters(), and send the complete text in one go. It will
also take out the \n and \t from the beginning of the text and the end
of the text.
I found out later that there is a XMLFilterImpl. It is interesting that
this class implements both the reader interface and all the handler
interface, whereas my decorator only implements the ContentHandler.
Just a personal opinion, I think my design can be a little be more
efficient. For example:
reader = XMLReaderFactory.createXMLReader();
handler = new SimpleHandler(); // Extends DefaultHandler
reader.setContentHandler(new BufferedHandler(handler));
reader.setErrorHandler(handler);
My design is easier to understand (implements only the handler part of
the interface) and it can prevent passing the call unnecessarily. (if
you are using XMLFilterImpl to create a filter for each of the
ContentHandler and ErrorHandler, this will cause extra calls across
layers.)
Anyone think the same as me?