This week's book giveaway is in the OCPJP forum.
We're giving away four copies of OCA/OCP Java SE 7 Programmer I & II Study Guide and have Kathy Sierra & Bert Bates on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes Problem with SAXParser Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA/OCP Java SE 7 Programmer I & II Study Guide this week in the OCPJP forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Problem with SAXParser " Watch "Problem with SAXParser " New topic
Author

Problem with SAXParser

Balaji Natarajan
Greenhorn

Joined: Dec 05, 2002
Posts: 28
We are using Saxparser with weblogic 8.1 and JDK 1.4 .
One of the tags is getting parsed twice and the value in the field gets split into 2 separate values.
Whereas with weblogic7.0 , the same works fine.
Are there any known issues related to compatility with weblogic 8 and jdk 1.4?

Thanks in advance,
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

value in the field gets split into 2 separate values.

I hope you have considered the case where the characters method could be invoked multiple times.


Groovy
Ko Ko Naing
Ranch Hand

Joined: Jun 08, 2002
Posts: 3178
I think such kind of version-related questions about WebLogic is suitable for the WebLogic Forum. It is more likely that u will get the best solution for your question related to WebLogic Version there in that forum... All the best..


Co-author of SCMAD Exam Guide, Author of JMADPlus
SCJP1.2, CCNA, SCWCD1.4, SCBCD1.3, SCMAD1.0, SCJA1.0, SCJP6.0
Balaji Natarajan
Greenhorn

Joined: Dec 05, 2002
Posts: 28
Yes Pradeep.. the characters() method is called twice for the same tag.
I wd try to post this in the weblogic forum too.
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
Balaji, there is absolutely no guarantee that a SAX parser will invoke the characters() method only once for any text "field". You should simply be prepared for receiving multiple invocations of characters(), appending to a StringBuffer etc.


Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
Pradeep bhatt
Ranch Hand

Joined: Feb 27, 2002
Posts: 8919

For characters method, from the API
The Parser will call this method to report each chunk of character data. SAX parsers may return all contiguous character data in a single chunk, or they may split it into several chunks; however, all of the characters in any single event must come from the same external entity so that the Locator provides useful information.

Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9048
    
  10
Originally posted by Balaji Natarajan:
I wd try to post this in the weblogic forum too.

I suggest if you post in the WebLogic forum, that you post a link to this question in that post. We discourage duplicate posts here at JavaRanch. It can become very confusing very quickly.
[ February 26, 2004: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Balaji Natarajan
Greenhorn

Joined: Dec 05, 2002
Posts: 28
Thanks for all your inputs. Now i have changed the characters of method to check for multiple parses and is working fine..
Sorry i by mistake have posted the same query in weblogic forum !! Will avoid that in my future posts ...
Thanks a lot again..
Madhav Lakkapragada
Ranch Hand

Joined: Jun 03, 2000
Posts: 5040
Yesterday night, I found a good example of the characters( ) implementation in this article. Explains why and how to implement it.
Although, your issue is solved thought this would help anyone else who is curious....


Take a Minute, Donate an Hour, Change a Life
http://www.ashanet.org/workanhour/2006/?r=Javaranch_ML&a=81
 
Consider Paul's rocket mass heater.
 
subject: Problem with SAXParser