Desarrollando los atributos
This commit is contained in:
parent
2ad629cfac
commit
40d5f0f811
62
xsd.md
62
xsd.md
|
|
@ -68,13 +68,67 @@ elementFormDefault="qualified">
|
|||
Los elementos simples solo pueden contener texto. La diferencia entre fixed y default es que en que con fixed, el valor no se puede modificar, tiene que ser ese, y con default si es modificable.
|
||||
|
||||
```xml
|
||||
<xs:element name="nombre_del_elemento" type="tipo_de_dato"/>
|
||||
<xs:element name="nombre_del_elemento" type="tipo_de_dato" fixed="cadena"/>
|
||||
<xs:element name="nombre_del_elemento" type="tipo_de_dato" default="cadena"/>
|
||||
<xs:element name="nombre_del_elemento" type="xs:tipo_de_dato"/>
|
||||
<xs:element name="nombre_del_elemento" type="xs:tipo_de_dato" {fixed|default}="cadena"/>
|
||||
```
|
||||
|
||||
#### Atributos
|
||||
|
||||
##### Simples
|
||||
|
||||
```xml
|
||||
<xs:attribute name="nombre_del_atributo" type="tipo_de_dato"/>
|
||||
<!-- Simple -->
|
||||
<xs:attribute name="nombre_del_atributo" type="xs:tipo_de_dato"/>
|
||||
|
||||
<!-- Con valor por defecto -->
|
||||
<xs:attribute name="nombre_del_atributo" type="xs:tipo_de_dato" default="valor"/>
|
||||
|
||||
<!-- Con valor fijo -->
|
||||
<xs:attribute name="nombre_del_atributo" type="xs:tipo_de_dato" fixed="valor"/>
|
||||
|
||||
<!-- Obligatorio (por defecto es opcional-->
|
||||
<xs:attribute name="nombre_del_atributo" type="xs:tipo_de_dato" use="required"/>
|
||||
|
||||
<!-- Con faceta -->
|
||||
<xs:attribute name="nombre_atributo">
|
||||
<xs:simpleType>
|
||||
<xs:restriction base="xs:tipo_de_dato">
|
||||
<xs:pattern value="[A-D]{3}\d"/>
|
||||
</xs:restriction>
|
||||
</xs:simpleType>
|
||||
</xs:attribute>
|
||||
```
|
||||
|
||||
##### Complejos
|
||||
|
||||
```xml
|
||||
<!-- Elemento complejo vacio, con atributos -->
|
||||
<xs:element name="nombre_elemento">
|
||||
<xs:complexType>
|
||||
<xs:attribute name="nombre_atributo" type="xs:tipo_de_dato"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<!-- Elemento complejo con elementos, y atributos -->
|
||||
<xs:element name="nombre_elemento">
|
||||
<xs:complexType>
|
||||
<xs:sequence>
|
||||
<xs:element name="nombre_elemento" type="xs:tipo_de_dato"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="nombre_atributo" type="xs:tipo_de_dato"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
|
||||
<!-- Elemento complejo con texto, y atributos -->
|
||||
|
||||
|
||||
<!-- Elemento complejo con elementos, texto, y atributos -->
|
||||
<xs:element name="nombre_elemento">
|
||||
<xs:complexType mixed="true">
|
||||
<xs:sequence>
|
||||
<xs:element name="nombre_elemento" type="xs:tipo_de_dato"/>
|
||||
</xs:sequence>
|
||||
<xs:attribute name="nombre_atributo" type="xs:tipo_de_dato"/>
|
||||
</xs:complexType>
|
||||
</xs:element>
|
||||
```
|
||||
Loading…
Reference in New Issue