potential bug

There is a big assumption being made on the characters() call. The assumption that characters will be called once, with the all data, is wrong. characters() can be called multiple times with parts of the content data (which is why the interface is characters(chars, start, len)). You really should be building up the content in a member variable and handling it most likely in the endElement(), but it depends on the stucture of your XML. My advice would be to never do content handling in the characters method.

With small XML documents, you may not ever notice this, since the input stream won't hit a buffer boundary and characters() will only get called once, but as the XML gets bigger, you are more likely to run into it. It will manifest itself by not matching any of your elements. The XML will appear mangled, but when you look at the source XML, it looks fine.

XML Parsing With SAX and Xerces (part 2)

The first part of this article demonstrated the basics of the Xerces XML parser, explaining how it could be used to process XML documents in a non-Web environment. This concluding section closes the circle, taking everything you've learned so far and demonstrating how it can be applied to create dynamic Web pages from static XML documents with Xerces.

Please discuss this article in this thread. You can read the article here .