Altova Mailing List Archives>Archive Index >comp.text.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: SAX multiple calls to characters() SAX multiple calls to characters()To: NULL Date: 8/2/2006 8:44:00 AM
I am using the function listed below to handle characters events in
SAX. It does not handle multiple sequential calls to this function
correctly. For example, I am getting
"2 4 816 32 64" as a value for an element when processing <vec> 2 4 8
16 32 64 </vec>
because I am getting 2 calls to process the text in this element, one
for "2 4 8" and the other for "16 32 64". I have tried appending a
blank to the result after each call to this function, but that
sometimes splits numbers or words, depending on what is passed to this
function.
Is there a better way of handling multiple characters events? Thanks
public void characters(char[] chars, int start, int length) {
while ( (length > 0) && Character.isWhitespace(chars[start]) )
{
++start;
--length;
}
while ( (length > 0) &&
Character.isWhitespace(chars[start+length-1]) ) {
--length;
}
if ( length > 0 ) {
_text += new String(chars,start,length);
}
}
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
