I want to write an XSD file to validate the following XML
The xml
file:
<?xml version="1.0" encoding="UTF-8"?>
<eventos xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="eventos31.xsd">
<evento tipo="musical">
<compania>
<nombre_compania>La Joven Compañia</nombre_compania>
<interpretes>
<interprete codint="I1"> Javier Ariano</interprete>
<interprete codint="I2"> Alejandro Chaparro</interprete>
<interprete codint="I3"> Jesús Lavi</interprete>
<interprete codint="I4"> Rosa Martí</interprete>
<interprete codint="I5"> Laura Montesinos</interprete>
<interprete codint="I6"> Maria Romero</interprete>
<interprete codint="I7"> Ález Villazán</interprete>
<interprete codint="I8"> Jorge Yumar</interprete>
</interpretes>
<director-a> José Luis Arellano García</director-a>
<web_compania dirweb= "www.lajovencompania.com"/>
</compania>
<nombre_espectaculo>Priscila, reina del desierto</nombre_espectaculo>
<cuando>
<fecha dia="22" mes="febrero" anio="2018"/>
<hora inicio="20:30" fin="23:00"/>
</cuando>
<descripcion>Narra las aventuras de tres artistas drag</descripcion>
<precio>55€</precio>
<duracion>2h 30min</duracion>
</evento>
<evento tipo="magia">
<mago>
<nombre_mago> Jorge Blass</nombre_mago>
<mail dirmail= "naka@7rojo.com"/>
<shows>
<show codshow="C1"> Palabra de Mago</show>
<show codshow="C2"> Arte de la Magia</show>
<show codshow="C3"> Birlibirloque</show>
</shows>
</mago>
<nombre_espectaculo>Palabra de mago</nombre_espectaculo>
<cuando>
<fecha dia="02" mes="Junio" anio="2018"/>
<hora inicio="19:00" fin="20:30"/>
</cuando>
<descripcion>Trucos de magia de Jorge Blas</descripcion>
<precio>18€</precio>
<duracion>1h 30min</duracion>
</evento>
<evento tipo="humor">
<comico>
<nombre_comico> Dani Mateo</nombre_comico>
<ciudad> Granollers</ciudad>
<edad> 38</edad>
<redes_sociales>
<blog> danimateo.blogspot.com</blog>
<twitter> @DaniMateoAgain</twitter>
<facebook> @dani.mateo</facebook>
</redes_sociales>
</comico>
<nombre_espectaculo>Dani Mateo,10 aniversario</nombre_espectaculo>
<cuando>
<fecha dia="09" mes="Junio" anio="2018"/>
<hora inicio="20:30" fin="22:00"/>
</cuando>
<precio>21€</precio>
<duracion>1h 30min</duracion>
</evento>
This is, what I have tried so far
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="eventos">
<xs:complexType>
<xs:sequence>
<xs:element name="evento" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="compania">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre_compania" type="xs:string" />
<xs:element name="interpretes">
<xs:complexType>
<xs:sequence>
<xs:element name="interprete" maxOccurs="unbounded"/>
</xs:sequence>
<xs:attribute name="codint" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
<xs:element name="director-a" type="xs:string" />
<xs:element name="web_compania"/>
</xs:sequence>
<xs:attribute name="dirweb" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="nombre_espectaculo" type="xs:string" maxOccurs="unbounded"/>
<xs:element name="cuando">
<xs:complexType>
<xs:sequence>
<xs:element name="fecha"/>
<xs:element name="hora"/>
</xs:sequence>
<xs:attribute name="dia" type="xs:integer"/>
<xs:attribute name="mes" type="xs:string"/>
<xs:attribute name="anio" type="xs:integer"/>
<xs:attribute name="inicio" type="xs:string"/>
<xs:attribute name="fin" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="descripcion" type="xs:string"/>
<xs:element name="precio" type="xs:string"/>
<xs:element name="duracion" type="xs:string"/>
<xs:element name="mago" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre_mago" type="xs:string"/>
<xs:element name="mail"/>
<xs:element name="shows">
<xs:complexType>
<xs:sequence>
<xs:element name="show" type="xs:string"/>
</xs:sequence>
<xs:attribute name="codshow" type="xs:string" use="required"/>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="dirmail" type="xs:string"/>
</xs:complexType>
</xs:element>
<xs:element name="comico" minOccurs="0">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre_comico" type="xs:string"/>
<xs:element name="ciudad" type="xs:string"/>
<xs:element name="edad" type="xs:integer"/>
<xs:element name="redes_sociales">
<xs:complexType>
<xs:sequence>
<xs:element name="blog" type="xs:string"/>
<xs:element name="twitter" type="xs:string"/>
<xs:element name="facebook" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:sequence>
<xs:attribute name="tipo" type="xs:string"/>
</xs:complexType>
</xs:element>
</xs:sequence>
</xs:complexType>
</xs:element>
Using xmllint xmllint -schema eventos31.xsd 48985313.xml
I get
48985313.xml:6: element interpretes: Schemas validity error : Element 'interpretes': The attribute 'codint' is required but missing.
48985313.xml:29: element mago: Schemas validity error : Element 'mago': This element is not expected. Expected is ( compania ).
48985313.xml:48: element comico: Schemas validity error : Element 'comico': This element is not expected. Expected is ( compania ).
48985313.xml fails to validate
What is the easiest way to get a XSD for an existing XML file?