[relaxng-user] preferred implementation for error reporting
Daniel Veillard
veillard at redhat.com
Fri Mar 11 07:14:33 ICT 2005
On Fri, Mar 11, 2005 at 12:25:27PM +0100, Robin Berjon wrote:
> Hi,
>
> I've been trying to debug a rather lengthy RNG and am running up against
> the somewhat enigmatic errors reported by most implementations... If I
> run both jing and xmllint I tend to get a feel for what's wrong but it's
> still far from ideal.
>
> So before I go hunting, is there an implementation of RNG that has
> precise error reporting?
First I don't expect xmllint to have very good RNG error reporting.
This is due to the state based approach of the validation, and basically
it doesn't allow to extract what really went wrong. But I would expect
jing to have as mathematically exact as possible error reporting, see
the notes from James about how he does
http://www.thaiopensource.com/relaxng/derivative.html#Error_handling
But in general due to the extreme flexibility of Relax-NG it is hard
to provide the "best" error report. This is mostly due to the choice
construct, all cases of a choice may fail, the algorithm will usually
report the error about only one of them, but which one is the "closest"
in content to the actual content is rather hard to tell, and well
for example my error report mechanism will complain about the last branch.
For example
<element name="top">
<choice>
<element name="foo">
<attribute name="bar">
<text/>
</attribute>
<text/>
</element>
<element name="bar">
<text/>
</element>
<choice>
</element>
if trying to validate
<top>
<foo/>
</top>
you can argue that <foo/> is closer to <foo bar=""/> than <bar/>
and that the validator ought to raise a missing attribute error rather
than finding a foo element while bar is expected. But 1/ it's really
human thinking 2/ this is really a trivial example, real life schemas
are way more complex. In general providing a human friendly error reporting
from a Relax-NG validator sounds to me harder than building a validator
in the first place.
So I don't have an answer, but I have a potential explanation :-)
Daniel
--
Daniel Veillard | Red Hat Desktop team http://redhat.com/
veillard at redhat.com | libxml GNOME XML XSLT toolkit http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine http://rpmfind.net/
More information about the relaxng-user
mailing list