You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-dev@xerces.apache.org by Dream Catcher <is...@leonis.nus.edu.sg> on 2001/01/07 05:42:15 UTC

DOM Parser

Hi, all. 

In my program I use Xerces1.2.3's DOM parser to parse my .xml file whose
grammar is in .xsd file. I discover even I omit
  xmlns:xsi='http://www.w3.org/1999/XMLSchema-instance'
  xsi:noNamespaceSchemaLocation='document.xsd' 
in the root level element the parser doesn't complain at all. And I add
some undefined elments into the document.xml file on purpose, the DOM
parser doesn't complain either!!! It seems the grammar doesn't govern my
document.xml file at all. May I know where is my fault? I have already
done this in my program:
  DOMParser p = new DOMParser();
  p.setFeature("http://xml.org/sax/features/validation", true);
  p.setFeature("http://apache.org/xml/features/validation/schema", true);


  thanks...

Best Regards
Wang Yue

    *------------------------------*
      Attitude makes the difference
    *------------------------------*



Re: DOM Parser

Posted by David Halsted <ha...@tcimet.net>.
Have a look at the sample code that ships with Xerces.  The source for
DOMCount, I think it is, has a pretty complete set of examples of
error-handling.

----- Original Message -----
From: Milind Gadre <mi...@ecplatforms.com>
To: <xe...@xml.apache.org>
Sent: Sunday, January 07, 2001 10:55 AM
Subject: Re: DOM Parser


> Perhaps you need to associate an error handler with the parser, and
> throw an exception for any error/fatalError that is encountered.
>
> Regards...
>
> Milind Gadre
> ecPlatforms, Inc
> 901 Mariner's Island Blvd, Suite 565
> San Mateo, CA 94404
> C: 510-919-0596
> F: 815-352-0779
> milind@ecplatforms.com
>
> ----- Original Message -----
> From: "Dream Catcher" <is...@leonis.nus.edu.sg>
> To: <xe...@xml.apache.org>
> Sent: Saturday, January 06, 2001 8:42 PM
> Subject: DOM Parser
>
>
> > document.xml file at all. May I know where is my fault? I have already
> > done this in my program:
> >   DOMParser p = new DOMParser();
> >   p.setFeature("http://xml.org/sax/features/validation", true);
> >   p.setFeature("http://apache.org/xml/features/validation/schema",
> true);
> >
> >
> >   thanks...
> >
> > Best Regards
> > Wang Yue
> >
> >     *------------------------------*
> >       Attitude makes the difference
> >     *------------------------------*
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> > For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
> >
> >
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>


Re: DOM Parser

Posted by Andy Clark <an...@apache.org>.
Milind Gadre wrote:
> Andy, it would make sense to have this default behavior in the case
> where validation is set to true. It *is* confusing (initially) when you

Those were also my thoughts. And in non-validating mode, the
parser knows not to report validation warnings and errors. But
even in non-validating mode the user would see the report of
fatal errors.

> tell the parser 'validate', and see nothing even when things are
> obviously wrong.

And it's one of the most reported "bugs". So the new default
behavior will really help in that respect.

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: DOM Parser

Posted by Milind Gadre <mi...@ecplatforms.com>.
Andy, it would make sense to have this default behavior in the case
where validation is set to true. It *is* confusing (initially) when you
tell the parser 'validate', and see nothing even when things are
obviously wrong.

Regards...

> To avoid questions like this in the future, I changed Xerces2
> recently to install an error handler by default whose error
> messages are printed to standard out. Should do the same with
> Xerces 1.x?



Re: DOM Parser

Posted by Andy Clark <an...@apache.org>.
Milind Gadre wrote:
> Perhaps you need to associate an error handler with the parser, and
> throw an exception for any error/fatalError that is encountered.

To avoid questions like this in the future, I changed Xerces2
recently to install an error handler by default whose error
messages are printed to standard out. Should do the same with 
Xerces 1.x?

-- 
Andy Clark * IBM, TRL - Japan * andyc@apache.org

Re: DOM Parser

Posted by Milind Gadre <mi...@ecplatforms.com>.
Perhaps you need to associate an error handler with the parser, and
throw an exception for any error/fatalError that is encountered.

Regards...

Milind Gadre
ecPlatforms, Inc
901 Mariner's Island Blvd, Suite 565
San Mateo, CA 94404
C: 510-919-0596
F: 815-352-0779
milind@ecplatforms.com

----- Original Message -----
From: "Dream Catcher" <is...@leonis.nus.edu.sg>
To: <xe...@xml.apache.org>
Sent: Saturday, January 06, 2001 8:42 PM
Subject: DOM Parser


> document.xml file at all. May I know where is my fault? I have already
> done this in my program:
>   DOMParser p = new DOMParser();
>   p.setFeature("http://xml.org/sax/features/validation", true);
>   p.setFeature("http://apache.org/xml/features/validation/schema",
true);
>
>
>   thanks...
>
> Best Regards
> Wang Yue
>
>     *------------------------------*
>       Attitude makes the difference
>     *------------------------------*
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
> For additional commands, e-mail: xerces-j-dev-help@xml.apache.org
>
>