Hmm... now, I am seeing similar problem with SAXParserFactory, and enabling 
namespace support does not help.  Any ideas?  Thanks in adv,

ps. here's the code snippet:

SAXParserFactory spf = SAXParserFactory.newInstance();
spf.setValidating(true);
spf.setNamespaceAware(true);
SAXParser sp = spf.newSAXParser();
sp.parse(new InputSource(args[0]),
         new HandlerBase() {
           public void error(SAXParseException e) {
             System.out.println("Error: " + e.getMessage());
           }
           public void fatalError(SAXParseException e) {
             System.out.println("Fatal Error: " + e.getMessage());
           }
           public void warning(SAXParseException e) {
             System.out.println("Warning: " + e.getMessage());
           }
         }
        );

>From: Edwin Goei <[EMAIL PROTECTED]>
>Reply-To: [EMAIL PROTECTED]
>To: [EMAIL PROTECTED]
>Subject: Re: JAXP problem
>Date: Tue, 31 Jul 2001 19:19:55 -0700
>
>Min Lee wrote:
> >
> > Hi all,
> >
> > I'm having a strange problem with Xerces (1.3.1) and JAXP.  It seems 
>that if
> > I use the DOMParser.parse(String) to parse (with validation enabled)
> > data/personal-schema.xml, I have no problem.  However, if I parse the 
>same
> > file using DocumentBuilder API, it seems the parser cannot find the
> > personal.xsd and complains that the elements are not declared.  I've 
>seen
> > similar behaviour for SAXParser.
> >
> > A snippet of my test program:
> > ...
> > DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
> > dbf.setValidating(true);
> > DocumentBuilder db = dbf.newDocumentBuilder();
> > Document doc = db.parse(args[0]);
> > ...
> >
> > and the error, from the default error handler is:
> >
> > Error: URI=file:///E:/personal-schema.xml Line=3: Element type 
>"personnel"
> > must be declared.
> >
> > I've seen this happen 1.4.1 release as well.  Any ideas?  Thanks in 
>advance
> > for your help,
>
>OK, my initial evaluation was wrong, sorry.  The problem is that you
>need to turn on Namespace processing in the parser with JAXP.  So for
>example, before creating the DocumentBuilder, add this line:
>
>dbf.setNamespaceAware(true);
>
>The reason for this is historical.  JAXP 1.0 defined the default value
>to be false, then SAX 2.0 came along and defined a "namespaces" feature
>with a default of true, then JAXP 1.1 came along and had to maintain
>backward compatibility with JAXP 1.0.  The reason it works if you use
>Xerces implementation classes directly is because Xerces has a default
>value of true.
>
>So to summarize, I think what is going on here is that even though the
>XSD file does not use a targetNamespace, the instance document must use
>namespaces to point to the XSD file so the parser still needs to have
>namespaces turned on.  Hopefully someone will correct me if I am wrong.
>
>-Edwin
>
>---------------------------------------------------------------------
>To unsubscribe, e-mail: [EMAIL PROTECTED]
>For additional commands, e-mail: [EMAIL PROTECTED]
>


_________________________________________________________________
Get your FREE download of MSN Explorer at http://explorer.msn.com/intl.asp


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

Reply via email to