SAX Parser not reading after newline

java, sax

Solution

According to SAX parser specification, you may be getting multiple callbacks for `characters`, representing chunks of the same character block. You should combine consecutive ones into a single string.

The Parser will call [`characters`] method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

Problem

I am using the SAX parser to parse preformed text as listed below: ``` <content><![CDATA[(a) Definitions. (i) term - Definition of term (ii) term 2 - Definition of term 2 (iii) term 3 - Definition of term 3]]> </content> ``` My handler ``` public void characters(char ch[], int start, int length){ if (content) { contentText = new String(ch, start, length)); } } ``` However I am only getting the first line "(a) Definitions. " in my character buffer. The other lines are not being copied. How can I access the missing lines? Thank You.

Original source