XML Schema and Data Structure Examples
Video Game Catalog (Videojuegos)
Below is the XSD Schema for the video game catalog:
<xs:element name="catalogoVideojuegos">
<xs:complexType>
<xs:sequence>
<xs:element name="videojuego" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="titulo" type="xs:string"/>
<xs:element name="plataforma" type="tipoPlataforma"/>
<xs:element name="precio">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="fechaLanzamiento" type="xs:date"/>
<xs:element name="multijugador" type="xs:boolean"/>
</xs:sequence>
<xs:attribute name="codigo" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="[A-Z]{3}-[0-9]{3}"/>Faltan etiquetas por cerrar.
XML Data Instance:
<catalogoVideojuegos>
<videojuego codigo="FIF-123">
<titulo>FIFA 24</titulo>
<plataforma>PlayStation</plataforma>
<precio>59.99</precio>
<fechaLanzamiento>2024-09-20</fechaLanzamiento>
<multijugador>true</multijugador>
</videojuego>
<videojuego codigo="ZEL-456">
<titulo>Zelda Breath of the Wild</titulo>
<plataforma>Nintendo</plataforma>
<precio>49.95</precio>
<fechaLanzamiento>2017-03-03</fechaLanzamiento>
<multijugador>false</multijugador>
</videojuego>
</catalogoVideojuegos>Function Library (Biblioteca de Funciones)
The following XML represents a function library:
<bibliotecaFunciones>
<funcion version="1.0">
<nombre>calcularMedia</nombre>
<lenguaje>Java</lenguaje>
<lineasCodigo>25</lineasCodigo>
<retornaValor>true</retornaValor>
</funcion>
<funcion version="2.3">
<nombre>ordenarLista</nombre>
<lenguaje>Python</lenguaje>
<lineasCodigo>40</lineasCodigo>
<retornaValor>false</retornaValor>
</funcion>
</bibliotecaFunciones>Movie Billboard (Cartelera)
XSD Schema Definition:
<xs:element name="cartelera">
<xs:complexType>
<xs:sequence>
<xs:element name="pelicula" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="titulo" type="xs:string"/>
<xs:element name="director" type="xs:string"/>
<xs:element name="duracion">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minExclusive value="60"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="genero" type="tipoGenero"/>
<xs:element name="anio">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="1900"/>
<xs:maxInclusive value="2100"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="clasificacion" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:enumeration value="G"/>
<xs:enumeration value="PG"/>
<xs:enumeration value="PG-13"/>
<xs:enumeration value="R"/>
</xs:restriction>Falta cerrar etiquetas.
XML Data Instance:
<cartelera>
<pelicula clasificacion="PG-13">
<titulo>Inception</titulo>
<director>Christopher Nolan</director>
<duracion>148</duracion>
<genero>cienciaFiccion</genero>
<anio>2010</anio>
</pelicula>
<pelicula clasificacion="R">
<titulo>Joker</titulo>
<director>Todd Phillips</director>
<duracion>122</duracion>
<genero>drama</genero>
<anio>2019</anio>
</pelicula>
</cartelera>Furniture Catalog (Catálogo de Muebles)
XML Data Instance:
<catalogoMuebles>
<mueble referencia="MUE-1234">
<nombre>Mesa comedor</nombre>
<material>madera</material>
<peso>25.5</peso>
<color>roble</color>
<stock>10</stock>
</mueble>
<mueble referencia="MUE-5678">
<nombre>Estantería</nombre>
<material>metal</material>
<peso>15.75</peso>
<color>negro</color>
<stock>0</stock>
</mueble>
</catalogoMuebles>XSD Schema Definition:
<xs:element name="catalogoMuebles">
<xs:complexType>
<xs:sequence>
<xs:element name="mueble" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="nombre" type="xs:string"/>
<xs:element name="material" type="tipoMaterial"/>
<xs:element name="peso">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="color" type="xs:string"/>
<xs:element name="stock">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="referencia" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="MUE-[0-9]{4}"/>Falta cerrar etiquetas.
Course Platform (Plataforma de Cursos)
XML Data Instance:
<plataforma>
<curso codigo="CUR101" activo="true">
<titulo>Introducción a XML</titulo>
<horas>20</horas>
<nivel>basico</nivel>
<precio>0</precio>
</curso>
<curso codigo="CUR205" activo="false">
<titulo>XSD Avanzado</titulo>
<horas>35</horas>
<nivel>avanzado</nivel>
<precio>120.50</precio>
</curso>
</plataforma>XSD Schema Definition:
<xs:element name="plataforma">
<xs:complexType>
<xs:sequence>
<xs:element name="curso" maxOccurs="unbounded">
<xs:complexType>
<xs:sequence>
<xs:element name="titulo" type="xs:string"/>
<xs:element name="horas">
<xs:simpleType>
<xs:restriction base="xs:integer">
<xs:minExclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
<xs:element name="nivel" type="tipoNivel"/>
<xs:element name="precio">
<xs:simpleType>
<xs:restriction base="xs:decimal">
<xs:minInclusive value="0"/>
</xs:restriction>
</xs:simpleType>
</xs:element>
</xs:sequence>
<xs:attribute name="codigo" use="required">
<xs:simpleType>
<xs:restriction base="xs:string">
<xs:pattern value="CUR[0-9]{3}"/>
</xs:restriction>
</xs:simpleType>
</xs:attribute>
<xs:attribute name="activo" type="xs:boolean" use="optional"/>Faltan etiquetas por cerrar.
