[Home] [By Thread] [By Date] [Recent Entries]

  • From: Francis Norton <francis@r...>
  • To: Jeni Tennison <mail@j...>
  • Date: Fri, 15 Jun 2001 14:08:18 +0100



Jeni Tennison wrote:
> 
> RELAX NG doesn't require deterministic patterns; the following
> schema should do it:
> 
<snip/>

Yes, I got this to work with James Clark's jing
(http://www.thaiopensource.com/relaxng/):

<grammar xmlns="http://relaxng.org/ns/structure/0.9">
   <start>
      <element name="game">
         <element name="white">
            <ref name="move"/>
         </element>
         <zeroOrMore>
            <element name="black">
               <ref name="move"/>
            </element>
            <element name="white">
               <ref name="move"/>
            </element>
         </zeroOrMore>
         <optional>
            <element name="black">
               <ref name="move"/>
            </element>
         </optional>
      </element>
   </start>
   <define name="move">
      <text/>
   </define>
</grammar>

The grammar expanded a bit because you can't simply say <element
name="white/>, you have to put in some kind of content description, even
if only <text/> or <empty/>, so I created a common type, move. 
 
> XML Schema forces deterministic model groups, so you can't use that.
>
Interesting.

<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
elementFormDefault="qualified">
   <xs:element name="game">
      <xs:complexType>
         <xs:sequence>
            <xs:element ref="white"/>
            <xs:sequence minOccurs="0" maxOccurs="unbounded">
               <xs:element ref="black"/>
               <xs:element ref="white"/>
            </xs:sequence>
            <xs:element ref="black" minOccurs="0"/>
         </xs:sequence>
      </xs:complexType>
   </xs:element>
   <xs:element name="black">
      <xs:complexType/>
   </xs:element>
   <xs:element name="white">
      <xs:complexType/>
   </xs:element>
</xs:schema>

is an XML Schema equivalent.

XSV and MSXML4 detect the ambiguous content model, XML Spy 4 beta 1
ignores it and validates correctly.

Francis.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member