freaking1 / jing-trang

Automatically exported from code.google.com/p/jing-trang
Other
1 stars 0 forks source link

Store location information and report errors using that location information #115

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
The SchemaBuilder interface defines methods having a locator parameter. The 
implementation from com.thaiopensource.relaxng.input.parse uses that 
information but the implementation from the pattern module, 
com.thaiopensource.relaxng.pattern uses the Locator only for some patterns. 
This results in reporting errors without any location information. 
A sample schema for which Jing does not report any location on the error is:

<grammar xmlns="http://relaxng.org/ns/structure/1.0"
  datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
  <start>
    <oneOrMore>
      <element name="test">
        <empty/>
      </element>
    </oneOrMore>
  </start>
</grammar>

for which Jing gets only an error message
"found element matching the prohibited path start//oneOrMore in the simplified 
XML form of the schema (see section 7.1 of the RELAX NG specification)"
A possible location associated with this error would be the location of the 
oneOrMore pattern in the schema, but that cannot be set now because there is no 
locator stored for the oneOrMore pattern.
So basically there will be two steps:

1. Add a Locator parameter on the make... methods from PatternBuilder and in 
the derived classes (SchemaPatternBuilder and ValidatorPatternBuilder) and then 
pass that along to the created patterns (the patterns that do not store a 
locator need to be changed to allow setting them a locator)

2. Enhance the exceptions with location information where we do not set that, 
for example the checkRestrictions methods from most of the patterns.

Original issue reported on code.google.com by georgebina76 on 10 Jun 2010 at 1:09

GoogleCodeExporter commented 9 years ago
A good error message ought to include the location of both the <start> and 
<oneOrMore> elements.

Original comment by jjc.jclark.com on 24 Aug 2010 at 4:30