Why won't this Schema validate this XML file?

Posted by Sergio Tapia on Stack Overflow See other posts from Stack Overflow or by Sergio Tapia
Published on 2010-04-12T15:42:10Z Indexed on 2010/04/12 17:33 UTC
Read the original article Hit count: 619

Filed under:
|
|

The XML file:

<Lista count="3">
  <Pelicula nombre="Jurasic Park 3">
    <Genero>Drama</Genero>
    <Director sexo="M">Esteven Spielberg</Director>
    <Temporada>
       <Anho>2002</Anho>
       <Semestre>Verano</Semestre>
    </Temporada>
  </Pelicula>
  <Pelicula nombre="Maldiciones">
    <Genero>Ficcion</Genero>
    <Director sexo="M">Pedro Almodovar</Director>
    <Temporada>
       <Anho>2002</Anho>
       <Semestre>Verano</Semestre>
    </Temporada>
  </Pelicula>
  <Pelicula nombre="Amor en New York">
    <Genero>Romance</Genero>
    <Director sexo="F">Katia Hertz</Director>
    <Temporada>
       <Anho>2002</Anho>
       <Semestre>Verano</Semestre>
    </Temporada>
  </Pelicula>
</Lista>

And here's the XML Schema file I made, it's not working. :\

<xsd:complexType name="Lista">
  <xsd:attribute name="count" type="xsd:integer" />
  <xsd:complexContent>
    <xsd:element name="Pelicula" type="xsd:string">
      <xsd:attribute name="nombre" type="xsd:string" />
      <xsd:complexType>
        <xsd:sequence>
          <xsd:element name="Genero" type="generoType"/>
          <xsd:element name="Director" type="directorType">
            <xsd:attribute name="sexo" type="sexoType"/>
          </xsd:element>
          </xsd:element name="Temporada">
           <xsd:complexType>
             <xsd:sequence>
               <xsd:element name="Anho" type="anhoType" />
               <xsd:element name="Semestre" type="semestreType" />
             </xsd:sequence>
           </xsd:complexType>
          <xsd:element></xsd:element>
        </xsd:sequence>
      </xsd:complexType>
    </xsd:element>
  </xsd:complexContent>
</xsd:complexType>

<xsd:simpleType name="sexoType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="F"/>
    <xsd:enumeration value="M"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="directorType">
  <xsd:restriction base="xsd:string" />
</xsd:simpleType>

<xsd:simpleType name="generoType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Drama"/>
    <xsd:enumeration value="Accion"/>
    <xsd:enumeration value="Romance"/>
    <xsd:enumeration value="Ficcion"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="semestreType">
  <xsd:restriction base="xsd:string">
    <xsd:enumeration value="Verano"/>
    <xsd:enumeration value="Invierno"/>
  </xsd:restriction>
</xsd:simpleType>

<xsd:simpleType name="anhoType">
  <xsd:restriction base="xsd:integer">
    <xsd:minInclusive value="1970"/>
    <xsd:maxInclusive value="2020"/>
  </xsd:restriction>
</xsd:simpleType>

© Stack Overflow or respective owner

Related posts about xsd

Related posts about xml-schema