tksk / jing-trang

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

Incorrect line:column number in error description #148

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Unzip attached DTD.zip at C:\Project\Cochrane
Use attached parse.bat file for parsing and put files as mentioned in this file
2. command at dos prompt: parse cca18.xml Cochrane
3. Will show the below mentioned error message at c:\jing-20091111\error.log
 file

What is the expected output? What do you see instead?
Line and column number of error should be 100% accurate in error. Here column 
number showing '59' instead of '26' for the error

c:\Project\Cochrane\17-Jan-12\cca18\cca18.xml:54:26: error: attribute "gent" 
not allowed here; ......

coming as
c:\Project\Cochrane\17-Jan-12\cca18\cca18.xml:54:59: error: attribute "gent" 
not allowed here; ....

What version of the product are you using? On what operating system?
jing-20091111
windows-xp

Please provide any additional information below.

Original issue reported on code.google.com by k.prasa...@gmail.com on 18 Jan 2012 at 12:47

Attachments:

GoogleCodeExporter commented 9 years ago
Hi,

There is no such rule that the line/column information will provide a 100% 
accurate information - it is not even possible because that will show only one 
location in the document while an error would be accurately located with a 
range or a set of ranges. The error location just indicates the place of the 
error and in general it points to a location after the content that caused the 
error.

In your case

<event type="xmlCreated" gent="Aptara" date="2012-05-01"/>

you have an attribute "gent" instead of "agent" and Jing will point you to the 
end of the element while the error message clearly states the issue:

"attribute "gent" not allowed here; expected attribute "agent", "date", 
"ns1:chunk", "ns1:link", "ns2:link_version_label", "ns2:obj_id", 
"ns2:obj_status", "ns2:version_label", "onlyChannels" or "role" (with 
xmlns:ns1="http://cms.wiley.com" xmlns:ns2="http://www.documentum.com")

This comes from the fact that Jing acts as a content handler on the XML parser 
and the parser will notify Jing with different XML events like: start element, 
end element, empty element, text, etc. but there is no separate notification 
for each attribute, the attributes are notified as part of a start element or 
empty element notification. Such a notification comes also with a locator that 
provides location information and this locator points at the end location of 
the event notified, so in your case it points to the end of the element.

It is possible of course to identify that this error is related with an 
attribute and then try to look back and locate that attribute but this requires 
additional processing. The error reporting also needs enhancements to be able 
to report more than one line/column location as you may want to have both the 
start and the end location of the error in order to consider that accurate.

In oXygen XML Editor we use Jing for Relax NG validation and we added a post 
processing step on the errors reported by Jing and we try to compute better 
location information. For example, in this case we report the start location 
and the end location as below, identifying exactly the unexpected attribute:
Start location: 55:26
End location: 55:39 
so one possibility for you will be to do the same thing and compute better 
location info for the Jing reported errors by looking back into the document.

Issue 45 addresses enhancements on error reporting, maybe you should add a note 
there and vote for that issue (star the issue).

Original comment by georgebina76 on 27 Jan 2012 at 1:05