[relaxng-user] Ambiguity in RNC grammar

Jeff Rafter lists at jeffrafter.com
Sat May 8 09:29:47 ICT 2004

I have just about finished the translator I am working on for RNC->RNG. I
stumbled upon what I think is an ambiguity in the grammar. Because XML
allows for a "-" in a name, and RNC allows for "-" as part of a dataExcept
(or nameExcept)-- I think that there is a collision. Consider:

start = foo
foo = element foo { string-chars }
string-chars = element string-chars { string }
chars = "????????"

In the declaration of the element foo, what is expected? The child element
string-chars, or a string minus the value of chars?

This is obviously fringe case-- but then, that was why I wrote my own
parser/translator was to learn all of the fringe cases. Jing and
XMLDistilled are treating it as an XML name char (when there are no
spaces)-- which is what I was doing as well. This suggests that the
ambiguity could be clarified very easily with an addition to the
tokenization section about the precedence of "-".

In general this is good but can create other problems:

start = foo
foo = element foo { xsd:int-xsd:byte }

XMLDistilled passes this file, where Jing raises an error "datatype
'int-xsd' ... not recognized".

Is there a recommendation?

Jeff Rafter

More information about the relaxng-user mailing list