Question

I am writing an XML Schema for a database format for chess games. The moves are in a specific format which I validate with a regex; it looks something like this: <move>Pe2e4</move>. The <move&> element can also contain a <variation>' element. The problem is, I can't simply domixed="true"` because I need to validate the move. Here is the relevant part of the schema file:

<xs:element name="move">
    <xs:complexType>
        <xs:simpleContent>
            <xs:extension base="moveType">
                <xs:attribute ref="time"/>
                <xs:attribute ref="comment"/>
            </xs:extension>
        </xs:simpleContent>
        <xs:sequence>
            <xs:element ref="variation" minOccurs="0" maxOccurs="unbounded"/>
        </xs:sequence>
    </xs:complexType>
</xs:element>

moveType is the type for moves that does the validation.

So can someone explain how I can:

  1. have my move regex validation,
  2. have my <variation> element, and
  3. have my time and comment attributes.

BTW, the whole schema validates fine without the

<xs:sequence>
    <xs:element ref="variation" minOccurs="0" maxOccurs="unbounded"/>
</xs:sequence>

part.

Was it helpful?

Solution

I ended up reorganizing the schema thanks to the advice of Alejandro and Nic Gibson. The <variation> element is now outside of the <move> element.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top