tksk / jing-trang

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

error message doesn't allow to distinguish between two completely different grammar violations #160

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create 2 files with test grammars and 1 test xml file

GRAMMAR 1:

<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="M">
        <element name="C">
          <interleave>
            <choice>
              <element name="A">
                <text/>
              </element>
              <element name="B">
                <text/>
              </element>
            </choice>
            <element name="D">
              <text/>
            </element>
          </interleave>
        </element>
    </element>
  </start>
</grammar>

GRAMMAR 2:

<?xml version="1.0"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="M">
        <element name="C">
            <element name="D">
              <text/>
            </element>
        </element>
    </element>
  </start>
</grammar>

TEST XML FILE:

<?xml version="1.0"?>
<M>
<C>
</C>
</M>

2. run Jing validation twice on the test file, using the two grammars:
java -jar /home/thomasriga/bin/jing/bin/jing.jar test-grammar-1.rng test.xml
java -jar /home/thomasriga/bin/jing/bin/jing.jar test-grammar-2.rng test.xml

3.

What is the expected output? What do you see instead?
I expect to see this message when validating with GRAMMAR 1:

test-3.xml:4:5: error: element "C" incomplete; missing required element "D", 
and missing one of the elements in the collection ["A", "B"]

and this error message when validating with GRAMMAR 2:

test-3.xml:4:5: error: element "C" incomplete; missing required element "D"

In both cases, the output instead is:

test-3.xml:4:5: error: element "C" incomplete; missing required element "D"

It is impossible to distinguish between the two cases, even if the grammars are 
very different. 

What version of the product are you using? On what operating system?
Ubuntu Linux, Sun JDK 7, jing-20091111.zip

Please provide any additional information below.

I suggest to print the element names included in a <choice> section; this will 
suffice to distinguish between the two cases.

The offending piece of code is in PatternMatcher.java at line 269:

268         // XXX  Could do better here and describe what is required instead 
of what is possible
269         error("incomplete_element_required_elements_missing_expected",
270               errorArgQName(qName, name, context, false),
271               expectedContent(context));

Original issue reported on code.google.com by thomasr...@google.com on 4 Sep 2012 at 2:54