andyHa/scireumOpen — pull request #6 by jarannilsen (2013-08-22 13:06:13+00:00)
Title: Fix for characters not guaranteed to provide entire text elements

While processing large XML documents using your XMLReader, we came across a couple of instances where text elements would be cut off half way through for no apparent reason.

After investigating, we discovered this was due to DefaultHandler.characters not being guaranteed to receive all characters of a text element in one call [1]. According to the specification the characters has to be collected and the text node produced in endElement instead.

We came across this problem when Xerces was on our classpath. Without Xerces, this seems to not be a problem, but with Xerces being a widely used library, we figured others may need this fix as well.

The provided changes to XMLReader should resolve this issue, but we appreciate any feedback on our solution and any proposed changes to how the fix is implemented (apologies for the diff showing the entire file as changed. The important lines are 56-58, 62-67 and 83-90).

To see the issue with Xerces on the classpath, please see this branch of my fork: https://github.com/jarannilsen/scireumOpen/tree/failsWithXerces Run "mvn test" and the test will fail with a cut of version of "Description".

To see the fix with Xerces on the classpath, please see this branch of my fork: https://github.com/jarannilsen/scireumOpen/tree/worksWithXerces Run "mvn test" and the test will pass without any cut off text elements.

Hope this fix can be of help! :)

[1]: http://docs.oracle.com/javase/6/docs/api/org/xml/sax/ContentHandler.html#characters(char[], int, int)