[relaxng-user] Trang effects
Jochen Schwarze
jochen.schwarze at gmail.com
Mon Mar 21 14:26:00 ICT 2005
Hi all,
when working with James Clark's (extremely useful) trang RELAX NG to
XML Schema converter I noticed the following effect.
This piece of RNG grammar:
<element name="test1">
<interleave>
<element name="a1"><empty/></element>
<element name="b1"><empty/></element>
<element name="c1"><empty/></element>
</interleave>
</element>
translates to this:
<xs:element name="test1">
<xs:complexType>
<xs:all>
<xs:element ref="a1"/>
<xs:element ref="b1"/>
<xs:element ref="c1"/>
</xs:all>
</xs:complexType>
</xs:element>
which is perfect.
This piece of RNG grammar, however, which defines the same structure
using an additional ref:
<element name="test2">
<interleave>
<ref name="a2-type"/>
<element name="b2"><empty/></element>
<element name="c2"><empty/></element>
</interleave>
</element>
<!-- ... -->
<define name="a2-type">
<element name="a2"><empty/></element>
</define>
translates to this:
<xs:element name="test2">
<xs:complexType>
<xs:choice minOccurs="0" maxOccurs="unbounded">
<xs:element ref="a2"/>
<xs:element ref="b2"/>
<xs:element ref="c2"/>
</xs:choice>
</xs:complexType>
</xs:element>
The latter XSD much more permissive than the original RNG. Instead of
enforcing exacly one of each a2, b2, c2 element, it allows more than
one of these while requiring none.
Any ideas how to deal with this? Not using ref's inside interleave is
possible, of course, but it loses modularization.
Thanks,
Jochen
PS. I understand that RELAX NG's and XSD's schema models are
significantly different and that it is not possible to translate RELAX
NG's interleave to XSD in the gerenal case.
More information about the relaxng-user
mailing list