Jeetu,
XML error is not thrown through XMLException, it is issued through Error
Handler. So in sample Memparse, after you set the MemParseHandler as the
error handler:
MemParseHandlers handler;
parser.setErrorHandler(&handler);
The XML error will be issued through MemParseHandlers::fatalError.
I modified the gXmlInMemBuf by adding some leading spaces before xml decl, and
got the expected error message:
E:\>memparse
Fatal Error at (file prodInfo, line 1, char 9): The XML or Text declaration
must start at line/colum
n 1/1
Finished parsing the memory buffer containing the following XML statements:
<?xml version='1.0' encoding='ascii'?>
<!DOCTYPE company [
<!ELEMENT company (product,category,developedAt)>
<!ELEMENT product (#PCDATA)>
<!ELEMENT category (#PCDATA)>
<!ATTLIST category idea CDATA #IMPLIED>
<!ELEMENT developedAt (#PCDATA)>
]>
<company>
<product>XML4C</product>
<category idea='great'>XML Parsing Tools</category>
<developedAt>
IBM Center for Java Technology, Silicon Valley, Cupertino, CA
</developedAt>
</company>
Parsing took 100 ms (0 elements, 0 attributes, 0 spaces, 0 characters).
Tinny
[EMAIL PROTECTED] wrote:
> Peter,
> You could also try this out with the MemParse sample code that comes along
> with the package. If you modify the
> string in gXMLInMemBuf variable in MemParse.cpp from a well-formed XML
> string to a not well-formed one and try running the sample code, you will
> see the behavior that I am seeing. That is, it does not throw an
> XMLException ..... is this expected?
> -Jeetu
>
> > -----Original Message-----
> > From: Peter A. Volchek [mailto:[EMAIL PROTECTED]]
> > Sent: Tuesday, June 19, 2001 10:19 AM
> > To: [EMAIL PROTECTED]
> > Subject: Re: DOMParser does not report errors for XML that
> > are not well-formed
> >
> >
> > ----- Original Message -----
> > From: <[EMAIL PROTECTED]>
> > To: <[EMAIL PROTECTED]>
> > Sent: Tuesday, June 19, 2001 7:31 PM
> > Subject: DOMParser does not report errors for XML that are
> > not well-formed
> >
> >
> > > I am using a DOMParser instance to load XML from a string
> > or a file to a
> > DOM
> > > by calling the parse(InputSource...) method on the string.
> > When the XML
> > > string is not well-formed, I do not get any exceptions (I
> > am catching
> > > XMLException while parsing).
> > >
> > > So I looked at the MemParse sample code which uses a
> > SAXParser instance to
> > > do the same thing and which has also set error handlers and document
> > > handlers on the SAXParser instance. I modified the XML string in the
> > sample
> > > code so that it is no more well-formed. It too did not
> > report any errors
> > as
> > > well. Is this an expected behaviour? If so, then does one
> > have to set
> > custom
> > > document handlers on a parser instance and throw exceptions
> > if an XML that
> > > is parsed is not well-formed? Or is there some other way to
> > do it as well?
> > >
> > > Thanks in advance,
> > > Jeetu
> > >
> >
> > Didn't you forget to call parser.parse() ?
> > Post the piece of code where you initializes the InputSource
> > and sets the
> > Parser.
> >
> >
> > Peter A. Volchek
> > Software Engineer
> > Metis International, Inc.
> > [EMAIL PROTECTED]
> >
> >
> >
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [EMAIL PROTECTED]
> > For additional commands, e-mail: [EMAIL PROTECTED]
> >
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]