Hi Michael,

Thanks for the reply...your comments got me thinking so I went back to take
a look and you're right. The try/catch logic was preventing it from getting
to the "getDocument" statement (the returned error was a SAXException from
the parse step.)

Here's a more accurate code snippet of how it looks now (should've posted
this before!)

                DOMParser parser = new DOMParser(mySymbolTable,
myGrammarPool);
                
                try {
        
parser.setFeature("http://xml.org/sax/features/namespaces";, true);
        
parser.setFeature("http://xml.org/sax/features/validation";, true);
        
parser.setFeature("http://apache.org/xml/features/validation/schema";, true);
        
parser.setFeature("http://apache.org/xml/features/validation/schema-full-che
cking", true);
        
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
"http://www.w3.org/2001/XMLSchema";);                    
                        parser.parse(xmlDocument);
                } catch (SAXNotRecognizedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (SAXNotSupportedException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (SAXException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                } catch (IOException e) {
                        // TODO Auto-generated catch block
                        e.printStackTrace();
                }
                
                this.document = parser.getDocument();

Earlier ths getDocument statement was *in* the try block, so it wasn't
getting executed.

I't working like I expect it now. Thanks for the help!

Regards,
Ed

-----Original Message-----
From: Michael Glavassevich [mailto:[EMAIL PROTECTED]
Sent: Wednesday, March 02, 2005 5:17 PM
To: [EMAIL PROTECTED]
Subject: Re: Validate and continue after errors?


Hi Ed,

That could happen if the parser threw an exception from parse before the 
Document node is created, for instance from an IOException thrown from an 
unsuccessful attempt to open the URL you specified. I don't see a 
try/catch block in your code snippet. Is the parser returning normally?

"Murphy, Ed" <[EMAIL PROTECTED]> wrote on 03/02/2005 05:54:26 PM:

> Hi,
> 
> I'm using the DOMParser with validation and I would like to be able to
> validate the XML that I'm sucking in and parse what I can up to wherever 
an
> error might occur. Currently, the document reference is coming back 
null. Is
> this possible?
> 
> I'm porting & enhancing some code so I'm not totally clear on what all 
the
> settings below are doing and the various documentation I've scrounged
> (sun.com, apache.org, etc.) haven't answered my question. All comments
> welcome.
> 
> Regards,
> Ed
> 
> Some technical stuff...
> 
> String xmlDocument = "some_xml_file.xml";
> 
> DOMParser parser = new DOMParser(mySymbolTable, myGrammarPool)
> parser.setFeature("http://xml.org/sax/features/namespaces";, true);
> parser.setFeature("http://xml.org/sax/features/validation";, true);
> parser.setFeature("http://apache.org/xml/features/validation/schema";, 
true);
> 
parser.setFeature("http://apache.org/xml/features/validation/schema-full-che
> cking", true);
> 
parser.setProperty("http://java.sun.com/xml/jaxp/properties/schemaLanguage";,
> "http://www.w3.org/2001/XMLSchema";);
> parser.parse(xmlDocument);
> Document document = parser.getDocument();
> 
> This e-mail and any attachments are intended only for use by the
> addressee(s) named herein and may contain legally privileged and/or
> confidential information. If you are not the intended recipient of this
> e-mail, you are hereby notified any dissemination, distribution or 
copying
> of this email, and any attachments thereto, is strictly prohibited. If 
you
> receive this email in error please immediately notify the sender and
> permanently delete the original copy and any copy of any e-mail, and any
> printout thereof.
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 

Michael Glavassevich
XML Parser Development
IBM Toronto Lab
E-mail: [EMAIL PROTECTED]
E-mail: [EMAIL PROTECTED]


---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
This e-mail and any attachments are intended only for use by the
addressee(s) named herein and may contain legally privileged and/or
confidential information. If you are not the intended recipient of this
e-mail, you are hereby notified any dissemination, distribution or copying
of this email, and any attachments thereto, is strictly prohibited. If you
receive this email in error please immediately notify the sender and
permanently delete the original copy and any copy of any e-mail, and any
printout thereof.

---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to