Bug 23840

Summary: char[] in the character gets flooded
Product: Xerces-J Reporter: ckamala kannan <ckamalakannan>
Component: SAXAssignee: Xerces-J Developers Mailing List <xerces-j-dev>
Status: NEW ---    
Severity: blocker    
Priority: P3    
Version: 1.4.4   
Target Milestone: ---   
Hardware: Sun   
OS: Linux   

Description ckamala kannan 2003-10-15 14:36:27 UTC
In the DefaultHandler class , i am using the characters() by overriding it .
It is notified when the characters in the xml . But once the array reaches it 
max size 2048 . it recreates the array .ie.., a new array is created . The data 
in the previuos array is overwritten by the new array .

Ex: 

<sometag>want to display the name </sometag>

once the notification for the above is received with the values as follows

character(char ch[] ,int start ,int length )
1.) assume so far the ch[] is stored with 2042 characters .
2.) for this notification , the ch[] will have only the characters "want t" in 
the ch [].
3.) so in the next notification it will have the other part of the char "o 
display the name ". 
4.) so the previous value "want t" is missed .

One solution is to store the previous value "want t" in a temporary string and 
use them in the next notification .

But there is one issue we may not know when to use the previous value .
Because of 

* <sometag>want to display the name </sometag>
.
.
.
.
+ <sometag>show rollno</sometag>

1.) at * the ch[] may get exactly 2048 characters.
2.) Assume the next notification is at + . 
3.) then we should not use the prev.  value . Since it is esactly at the next 
notification.

So please investigate it and response me at ckamalakannan@netscape.net
Comment 1 Joe Kesselman 2003-10-15 15:11:10 UTC
Sounds like normal SAX operation. Text may be broken up into multiple calls to
characters(), and the array is not guaranteed to be retained from call to call
for buffer-management reasons. It's the application's responsibility to copy the
data it wishes to retain into whatever storage representation it considers
appropriate.