On Tue, 17 Jul 2001, Cox, Randy wrote: > I have encountered a problem in Xerces 1.2.0. During a SAX parse in the > characters(char [], int, int) method. The contents of the element I am > processing should be "1541". What I am seeing is: > > 1. characters(char [], int, int) is called once with a length of 2 resulting > in a value of "15". > 2. characters(char [], int, int) is called again with a length of 2 > resulting in a value of "41". > > I have the following questions? > > 1. Has this been corrected in a later version of Xerces? > 2. Is this something that my handler must deal with and if so can you direct > me to some code patterns for solving the problem?
The SAX spec says that a parser is free to report the text in a given element in a single call to characters, or in multiple calls, if that better suits the implementation. The handler is responsible for collecting the data together into a single string. The way I normally do this is by creating a StringBuffer in the startElement method, appending each chunk of characters to the buffer (it has an append(char[], start, length) method which makes this very easy), and call toString on the buffer in the endElement method. Ian -- Ian Roberts, Software Engineer DecisionSoft Ltd. Telephone: +44-1865-203192 http://www.decisionsoft.com --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
