Which parser are you using? and at what point of your code are you calling the parse method?
SAX uses the observer/observable design pattern and your handler (DefaultHandler in your case) is the observer and the parser (use XMLReader) is the observable.
XMLReader should open the URL (or the input stream) and starts parsing the XML and it notifies the observer (handler) when it starts an element, end an element, etc...
I think that's your problem, you are not parsing the XML. So write another class that gets an instance of the XMLReader (use the XMLReaderFactory.createXMLReader()) and then install the handler on it and then call it's parse method.
Hope that helps.
-ramin
| "Ranjith Kodikara"
<[EMAIL PROTECTED]>
11/04/2004 12:54 AM
|
|
Hi,
My XML parsing program contains two java classes. The SurveyReader.java extends DefaultHandler interface and contains startElement, endElement and characters methods. It has 5 Vector member variables defined.
In startElement method I create a new Hashtable.
In characteres method I populate that hashtable with put method.
In endElement method, I add the Hashtable to the Vector member variable.
My other java class PopWOTC.java extends VBean class, because I have developed that to embed in Oracle form and to put it to Oracle 9iAs.
In that class's popQuotation method, I instantiate the above mentioned SurveyReader class and execute the doTheWork method. ( The http url is accessed and there is no problem with it, because I have updated the java.policy file in the Oracle jinitiator.)
SurveyReader r = new SurveyReader();
r.doTheWork("http://ranjith:8080/itos/tour1.jsp?progyear="+progYr+"&progno="+progNo+"&tourseq="+tourSeq+"&sessionid="+sessionid+"");
System.out.println(r.evtdVect.toString() ) ===> returns [] evtdVect is the Vector Defined in SurveyReader class.
When doTheWork() method is executed, the Vector should have been filled with hashtables. But just after doTheWork method, I call r.evtdVect (The Vector defined in SurveyReader.java class), but its not been filled. At this moment I see that the startElement, characters and endElement methods are not finished executing. Actually I need to access the SurveyReader's Vector member variable from PopWOTC class after calling dotheWork method.
I think something wrong here with SAX; Xerces.
I attach the SurveyReader class herewith. I would be greatful for any help.
Thanks and best regards,
Ranjith
[EMAIL PROTECTED]
| |||||||||||||||
|
| |||||||||||||||
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
SurveyReader.java
Description: Binary data
--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]

