hanshuebner / jing-trang

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

Jing -s doesn't process element x {notAllowed} to notAllowed in certain situation #140

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. create a schema as follows: 

start = A | D
A = element A { B* & C? }
B = element B { text }
C = element C { E }
D = element D { B* & E? }
E = notAllowed

2. run jing -s 
3.

What is the expected output? What do you see instead?

Expected output is:

start = A | D
A = element A { B* }
D = element D { B* }
B = element B { text }

Instead I get

start = A | D
A = element A { B* & _1? }
D = element D { B* }
B = element B { text }
_1 = element * { notAllowed }

which is invalid because 
 ' element "B" can occur in more than one operand of "interleave" '

What version of the product are you using? On what operating system?
20091111

Please provide any additional information below.

Original issue reported on code.google.com by taraAt...@gmail.com on 7 Apr 2011 at 5:33

GoogleCodeExporter commented 9 years ago
It should output something like

_1 = element * - * { notAllowed }

(where * - * is a way of writing an empty name class).  It won't simplify out 
to notAllowed because of

  http://www.oasis-open.org/committees/relax-ng/spec-20011203.html#notAllowed

Bug is in 
comp.thaiopensource.relaxng.pattern.PatternDumper.NameClassDumper.visitNull()

Original comment by jjc.jclark.com on 7 Apr 2011 at 6:34

GoogleCodeExporter commented 9 years ago
Wouldn't
B = element B {notAllowed}

qualify as an unreachable define?
That could be removed according to the specs that you cite.

Original comment by taraAt...@gmail.com on 7 Apr 2011 at 7:12

GoogleCodeExporter commented 9 years ago
Sorry, I don't understand your point.

Original comment by jjc.jclark.com on 7 Apr 2011 at 12:09

GoogleCodeExporter commented 9 years ago
Yeah, on further thought, unreachable is no help in this situation.
But

element * - * { notAllowed }

is illegal (according to oXygen) - 'wildcard in except'

I may have to write a script to replace 
element * {notAllowed} with notAllowed and then run the simplifier again.
Only problem is, this could generate more such patterns, so an iteration might 
be required.

Wish the specs could be modified.

Original comment by taraAt...@gmail.com on 9 Apr 2011 at 6:57

GoogleCodeExporter commented 9 years ago
I had forgotten that the spec disallows element * - * { ... }.  There's no way 
to write a name class that matches no names.

This means that _1 is going to need to be defined as notAllowed.  This would 
make jing -s non-idempotent, which is rather ugly.

One possibility is to do an additional simplification stage after checking 
constraints.  But the possibility of recursion makes this non-trivial.

Original comment by jjc.jclark.com on 10 Apr 2011 at 1:14

GoogleCodeExporter commented 9 years ago
I am surprised you don't have to do recursion already. It would be guaranteed 
to terminate, though.

Another possibility, although less desirable from my point of view, would be to 
leave the line
B = element B {notAllowed}

unchanged. At least it would not produce invalid output.

Original comment by taraAt...@gmail.com on 10 Apr 2011 at 8:26

GoogleCodeExporter commented 9 years ago
In keeping with the initial example, that should be
C = element C {notAllowed}

Original comment by taraAt...@gmail.com on 6 Feb 2012 at 8:46