This week's book giveaway is in the Cloud/Virtualizaton forum.
We're giving away four copies of Mesos in Action and have Roger Ignazio on-line!
See this thread for details.
Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

SAX parser problem

 
Bignpsf
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 13061
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It seems that SAX worked that way!!!

thanks for the help!!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic