You are viewing a plain text version of this content. The canonical link for it is here.
Posted to j-users@xerces.apache.org by Rajiv Shivane <mu...@yahoo.com> on 2003/04/04 06:19:48 UTC

Error recovery while parsing XMLs ..

Hello all,

I need an XML parser which can recover from malformed
xml errors and continue parsing. I was trying to see
if there is a feature in the parser which can be
enabled to make this happen. If such a feature exists
can someone give me a reference on how to enable it.

I was looking at the sources and I think that the
feature does not exist currently. I was also looking
at the nekoHTML sources and saw that the recovery has
been coded explicitly in the scanner [and there is
also a TagBalancer filter]. Is such a feature planned
for the xml parser? Is some one working on it? Could
someone give me some pointers on how to go about doing
this?

Thanks!
Rajiv

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Error recovery while parsing XMLs ..

Posted by Rajiv Shivane <mu...@yahoo.com>.
Hi Neeraj,

Thanks for the prompt reply. I had tried this feature.
But I am not sure if continue-on-error is same as
error-recovery. When we continue on error, the parser
does not seem to take the grammar into consideration
and hence generates lots of spurious errors. On error
recovery I would expect the parser to proceed in a
normal fashion. But, you recommend it only at
development time as there are no guarantees on normal
operation of the parser after a recovery and since it
might result in infinite loops. 

For example for the following document framgment:

  <icon >
   <small-icon>stillTypingMygif
   <large-icon>/tmp/large.gif</large-icon> 
  </icon> 

the content model for small-icon has only #PCDATA. I
would expect the parser to recover by inserting
</small-icon> into the stream before encountering
<large-icon>. But the parser recovers by changing
</icon> to </small-icon>. This results in cascading
spurious errors.

How does the error recovery work? Could you give me
some pointers as to where I can look for it in the
sources? All I could see was that in case of a fatal
error if the feature is set, then the saxexception is
not propagated.

Would appreaciate any suggestions/pointers you can
provide.

Thanks!
Rajiv

--- Neeraj Bajaj <ne...@sun.com> wrote:
> 
> set the following  feature to true.
>
http://apache.org/xml/features/continue-after-fatal-error
> 
> You should be completely aware of the fact that
> there is no guarntee 
> that parser will behave in normal fashion after
> encountering fatal 
> error. It is advisable to use this feature only
> during development time 
> and NEVER at the production time. XML document
> should be corrected as 
> the first step. Please read the feature
> documentation [1] for more detail.
> 
> 
> [1] http://xml.apache.org/xerces2-j/features.html
> 
> 
> Neeraj
> 
> 

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-dev-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-dev-help@xml.apache.org


Re: Error recovery while parsing XMLs ..

Posted by Rajiv Shivane <mu...@yahoo.com>.
Hi Neeraj,

Thanks for the prompt reply. I had tried this feature.
But I am not sure if continue-on-error is same as
error-recovery. When we continue on error, the parser
does not seem to take the grammar into consideration
and hence generates lots of spurious errors. On error
recovery I would expect the parser to proceed in a
normal fashion. But, you recommend it only at
development time as there are no guarantees on normal
operation of the parser after a recovery and since it
might result in infinite loops. 

For example for the following document framgment:

  <icon >
   <small-icon>stillTypingMygif
   <large-icon>/tmp/large.gif</large-icon> 
  </icon> 

the content model for small-icon has only #PCDATA. I
would expect the parser to recover by inserting
</small-icon> into the stream before encountering
<large-icon>. But the parser recovers by changing
</icon> to </small-icon>. This results in cascading
spurious errors.

How does the error recovery work? Could you give me
some pointers as to where I can look for it in the
sources? All I could see was that in case of a fatal
error if the feature is set, then the saxexception is
not propagated.

Would appreaciate any suggestions/pointers you can
provide.

Thanks!
Rajiv

--- Neeraj Bajaj <ne...@sun.com> wrote:
> 
> set the following  feature to true.
>
http://apache.org/xml/features/continue-after-fatal-error
> 
> You should be completely aware of the fact that
> there is no guarntee 
> that parser will behave in normal fashion after
> encountering fatal 
> error. It is advisable to use this feature only
> during development time 
> and NEVER at the production time. XML document
> should be corrected as 
> the first step. Please read the feature
> documentation [1] for more detail.
> 
> 
> [1] http://xml.apache.org/xerces2-j/features.html
> 
> 
> Neeraj
> 
> 

__________________________________________________
Do you Yahoo!?
Yahoo! Tax Center - File online, calculators, forms, and more
http://tax.yahoo.com

---------------------------------------------------------------------
To unsubscribe, e-mail: xerces-j-user-unsubscribe@xml.apache.org
For additional commands, e-mail: xerces-j-user-help@xml.apache.org


Re: Error recovery while parsing XMLs ..

Posted by Neeraj Bajaj <ne...@sun.com>.

Rajiv Shivane wrote:

>Hello all,
>
>I need an XML parser which can recover from malformed
>xml errors and continue parsing. I was trying to see
>if there is a feature in the parser which can be
>enabled to make this happen. 
>
set the following  feature to true.
http://apache.org/xml/features/continue-after-fatal-error

You should be completely aware of the fact that there is no guarntee 
that parser will behave in normal fashion after encountering fatal 
error. It is advisable to use this feature only during development time 
and NEVER at the production time. XML document should be corrected as 
the first step. Please read the feature documentation [1] for more detail.


[1] http://xml.apache.org/xerces2-j/features.html


Neeraj


Re: Error recovery while parsing XMLs ..

Posted by Neeraj Bajaj <ne...@sun.com>.

Rajiv Shivane wrote:

>Hello all,
>
>I need an XML parser which can recover from malformed
>xml errors and continue parsing. I was trying to see
>if there is a feature in the parser which can be
>enabled to make this happen. 
>
set the following  feature to true.
http://apache.org/xml/features/continue-after-fatal-error

You should be completely aware of the fact that there is no guarntee 
that parser will behave in normal fashion after encountering fatal 
error. It is advisable to use this feature only during development time 
and NEVER at the production time. XML document should be corrected as 
the first step. Please read the feature documentation [1] for more detail.


[1] http://xml.apache.org/xerces2-j/features.html


Neeraj