M
metzger
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);
}
}
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);
}
}