By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,541 Members | 1,106 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,541 IT Pros & Developers. It's quick & easy.

SAX Question -

P: n/a
P G
Hello, I am faced with a problem trying to use SAX - my class is as shown.
The problem is that the data structure "cm" is getting populated correctly
when printed from the endDocument() callback method, but getModel() call
subsequently does not return the results of the parsed XML.

As I am relatively new to SAX, I am wondering why this is - it doesn't do me
any good to see my data structure lost, after I have successfully populated
it from XML!

Thanks, and please email me directly on the reply.
Thanks, Paul
pa********@NOSPAMcomcast.net

public class ContactsModelBuilder extends DefaultHandler {
protected ContactsModel cm;
...
public void buildModel (String filename) {
...
try {
SAXParser saxParser = factory.newSAXParser();
saxParser.parse(new File(filename), handler);
} catch (SAXParseException spe) {
...
}
public void endDocument()
throws SAXException
{
if (cm != null) {
// THIS CALL IS GOOD!
// THIS CALL IS GOOD!
// THIS CALL IS GOOD!
cm.print();
}
}

public ContactsModel getModel () {
// THIS CALL RETURNS NULL *AFTER* endDocument()
// THIS CALL RETURNS NULL *AFTER* endDocument()
// THIS CALL RETURNS NULL *AFTER* endDocument()
return cm;
}
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.