I handled this by setting up a StringBuffer and appending to it, using a boolean
switch on when processing the particular tag in startElement(), switch off when
done in endElement().
"Cox, Randy" <[EMAIL PROTECTED]> on 07/19/2001 09:58:04 AM
Please respond to [EMAIL PROTECTED]
To: "'[EMAIL PROTECTED]'"
<[EMAIL PROTECTED]>
cc: (bcc: Barry Nobel/IN/FIS)
Subject: RE: Error in Sax parser - CharDataChunk size
Thanks
After I posted my problem I found a reference that told me about this
behavior. (This is my first time using SAX).
Again
Thanks for your quick reply.
Randy
-----Original Message-----
From: Ian Roberts [mailto:[EMAIL PROTECTED]
Sent: Thursday, July 19, 2001 3:27 AM
To: Xerces-J-User (E-mail)
Subject: Re: Error in Sax parser - CharDataChunk size
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]