tksk / jing-trang

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

invalid trang output — overzealous optimization? #100

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
trang converts the RELAX NG (XML syntax) grammar found below to

 start = element ABC { xyz*? }
 xyz = element xyz { empty }

which is an obvious syntax error. One would expect

 start = element ABC { (xyz*)? }
 xyz = element xyz { empty }

I'm guessing that trang is noticing that there is a <group> around
only one thing, and thus reasons that it is not needed. I have tested
this with versions 20030619, 20091111, and whatever comes w/ oXygen
11.

Input grammar:

<?xml version="1.0" encoding="UTF-8"?>
<grammar xmlns="http://relaxng.org/ns/structure/1.0">
  <start>
    <element name="ABC">
      <optional>
        <group>
          <zeroOrMore>
            <ref name="xyz"/>
          </zeroOrMore>
        </group>
      </optional>
    </element>
  </start>
  <define name="xyz">
    <element name="xyz">
      <empty/>
    </element>
  </define>
</grammar>

See also http://tech.groups.yahoo.com/group/rng-users/message/1138 and
1139.

Original issue reported on code.google.com by syd.bau...@gmail.com on 22 Dec 2009 at 12:39

GoogleCodeExporter commented 9 years ago
This is a bug because of

http://www.relaxng.org/compact-20021121.html#nt-repeatedPrimary

A simpler example of the bug is:

<optional xmlns="http://relaxng.org/ns/structure/1.0">
  <zeroOrMore>
    <ref name="xyz"/>
  </zeroOrMore>
</optional>

The problem is that trang needs to generate parentheses in when a repetition is 
applied to a repetition.

Original comment by jjc.jclark.com on 22 Dec 2009 at 7:20

GoogleCodeExporter commented 9 years ago
Issue 112 has been merged into this issue.

Original comment by georgebina76 on 31 May 2010 at 12:01

GoogleCodeExporter commented 9 years ago

Original comment by georgebina76 on 1 Jun 2010 at 8:55

GoogleCodeExporter commented 9 years ago
Fixed in r2345. Thanks for reporting this issue.

Original comment by georgebina76 on 1 Jun 2010 at 9:03