0

I am coding on a simple game and writing the *.xsd file.

My Problem is that the element should have as a content a number between 1 and 6, and the attribute should have a number between 1 and 4.

here is my code, but it does not function cause of the types:

        <xsd:element name="roll" type="numb_1_and_6">
            <xsd:complexType>
                <xsd:attribute name="player" use="required">
                    <xsd:simpleType>
                        <xsd:restriction base="xsd:integer">
                            <xsd:minInclusive value="1" />
                            <xsd:maxInclusive value="4" />
                        </xsd:restriction>
                    </xsd:simpleType>
                </xsd:attribute>
            </xsd:complexType>
        </xsd:element>

<xsd:simpleType name="numb_1_and_6">
    <xsd:restriction base="xsd:integer">
        <xsd:minInclusive value="1" />
        <xsd:maxInclusive value="6" />
    </xsd:restriction>
</xsd:simpleType>

The Problem is the numb_1_and_6-Type and the complex Type... So how to fix that?

greetings and thx in advance

maximus
  • 11,264
  • 30
  • 93
  • 124
  • Possible duplicate: http://stackoverflow.com/questions/626319/add-attributes-to-a-simpletype-or-restrictrion-to-a-complextype-in-xml-schema – DRH Apr 07 '12 at 16:26

1 Answers1

1

You're missing the definition of the content, in your case simple since it extends a simple type:

<xsd:element name="roll"> 
    <xsd:complexType>
        <xsd:simpleContent>
            <xsd:extension base="numb_1_and_6">
                <xsd:attribute name="player" use="required"> 
                    <xsd:simpleType> 
                        <xsd:restriction base="xsd:integer"> 
                            <xsd:minInclusive value="1"/> 
                            <xsd:maxInclusive value="4"/> 
                        </xsd:restriction> 
                    </xsd:simpleType> 
                </xsd:attribute>                    
            </xsd:extension>
        </xsd:simpleContent>
    </xsd:complexType> 
</xsd:element> 
Petru Gardea
  • 21,373
  • 2
  • 50
  • 62