aspose file tools*
The moose likes Java in General and the fly likes SAX parser problem Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Java in General
Bookmark "SAX parser problem" Watch "SAX parser problem" New topic
Author

SAX parser problem

Bignpsf
Greenhorn

Joined: Oct 15, 2003
Posts: 5
Hi,
I�m trying to parse a XML file using SAX, it worked fine until i test with a larger file(about 12MB), in the characters() implementation, i�m trying to load the value into an object, but the object that comes with the characters()(the value of the element) comes wrong, i mean it comes but comes with less bytes.
explanation:
I make a System.out with the values of the offset and the length of the values of the elements, and most of the values became fine except some values that came with a byte less:
value : blabla , offset : 456 , length : 6
...
...
value : blabl , offset : 6662 , length : 5
anyone knows what the hell is going on in this class...
PS: i�ve extend the Class DefaultHandler of org.xml.sax.helpers.DefaultHandler;
PS2: the XML file it�s fine!! The values are OK!!!
William Brogden
Author and all-around good cowpoke
Rancher

Joined: Mar 22, 2000
Posts: 12788
    
    5
You should be aware that a single call to characters may not include all of the characters in a element due to the fact that SAX works on buffer loads. You need to accumulate characters until the event signifying the end of the element. This question really belongs in the XML forum.
Bill
Bignpsf
Greenhorn

Joined: Oct 15, 2003
Posts: 5
It seems that SAX worked that way!!!

thanks for the help!!
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: SAX parser problem