Tutorial XML

INICIO XML Introducción XML XML Cómo utilizar Árbol XML Sintaxis XML Elementos XML Atributos XML Espacios de nombres XML Pantalla XML Solicitud Http XML Analizador XML DOM XML XPath XML XML XSLT XQuery XML Enlace X XML Validador XML DTD XML Esquema XML Servidor XML Ejemplos XML Cuestionario XML Certificado XML

XML-AJAX

AJAX Introducción AJAX XMLHttp Solicitud AJAX Respuesta AJAX Archivo XML AJAX AJAXPHP Ajax ASP Base de datos AJAX Aplicaciones AJAX Ejemplos de AJAX

DOM XML

DOM Introducción Nodos DOM Acceso DOM Información del nodo DOM Lista de nodos DOM Atravesando DOM Navegación DOM DOM obtener valores Nodos de cambio de DOM Eliminar nodos DOM Nodos de reemplazo de DOM DOM Crear nodos Agregar nodos DOM Nodos de clonación de DOM Ejemplos de DOM

Tutorial XPath

Introducción a XPath Nodos XPath Sintaxis XPath Ejes XPath Operadores XPath Ejemplos de XPath

Tutorial XSLT

XSLT Introducción Idiomas XSL Transformación XSLT XSLT <plantilla> XSLT <valor-de> XSLT <para-cada> XSLT <ordenar> XSLT <si> XSLT <elegir> Aplicar XSLT XSLT en el cliente XSLT en el servidor XSLT Editar XML Ejemplos de XSLT

Tutorial de XQuery

Introducción a XQuery Ejemplo de XQuery XQuery FLWOR XQuery HTML Términos de XQuery Sintaxis XQuery XQuery Agregar Seleccionar XQuery Funciones XQuery

DTD XML

Introducción a DTD Bloques de construcción DTD Elementos DTD Atributos DTD Elementos DTD vs Attr Entidades DTD Ejemplos de DTD

Esquema XSD

XSD Introducción XSD Cómo XSD <esquema> Elementos XSD Atributos XSD Restricciones XSD

Complejo XSD

Elementos XSD XSD vacío Solo elementos XSD Solo texto XSD XSD mixto Indicadores XSD XSD <cualquiera> XSD <cualquieratributo> Sustitución XSD Ejemplo XSD

Datos XSD

Cadena XSD Fecha XSD XSD Numérico Miscelánea XSD Referencia XSD

Servicios Web

Servicios XML XML WSDL JABÓN XML XML RDF RSS XML

Referencias

Tipos de nodos DOM Nodo DOM Lista de nodos DOM DOM NamedNodeMap Documento DOM Elemento DOM Atributo DOM Texto DOM DOM CDATA Comentario DOM DOM XMLHttpSolicitud Analizador DOM Elementos XSLT Funciones XSLT/XPath

Elemento de esquema XML Elemento


❮ Referencia completa del esquema XML

Definición y uso

El elemento elemento define un elemento.

Información del elemento

  • Elementos principales: esquema, elección, todo, secuencia, grupo

Sintaxis

<element
id=ID
name=NCName
ref=QName
type=QName
substitutionGroup=QName
default=string
fixed=string
form=qualified|unqualified
maxOccurs=nonNegativeInteger|unbounded
minOccurs=nonNegativeInteger
nillable=true|false
abstract=true|false
block=(#all|list of (extension|restriction))
final=(#all|list of (extension|restriction))
any attributes
>

annotation?,(simpleType|complexType)?,(unique|key|keyref)*

</element>

(El signo ? declara que el elemento puede aparecer cero o una vez, y el signo * declara que el elemento puede aparecer cero o más veces dentro del elemento elemento)

Attribute Description
id Optional. Specifies a unique ID for the element
name Optional. Specifies a name for the element. This attribute is required if the parent element is the schema element
ref Optional. Refers to the name of another element. The ref attribute can include a namespace prefix. This attribute cannot be used if the parent element is the schema element
type Optional. Specifies either the name of a built-in data type, or the name of a simpleType or complexType element
substitutionGroup Optional. Specifies the name of an element that can be substituted with this element. This attribute cannot be used if the parent element is not the schema element
default Optional. Specifies a default value for the element (can only be used if the element's content is a simple type or text only)
fixed Optional. Specifies a fixed value for the element (can only be used if the element's content is a simple type or text only)
form Optional. Specifies the form for the element. "unqualified" indicates that this element is not required to be qualified with the namespace prefix. "qualified" indicates that this element must be qualified with the namespace prefix. The default value is the value of the elementFormDefault attribute of the schema element. This attribute cannot be used if the parent element is the schema element
maxOccurs Optional. Specifies the maximum number of times this element can occur in the parent element. The value can be any number >= 0, or if you want to set no limit on the maximum number, use the value "unbounded". Default value is 1. This attribute cannot be used if the parent element is the schema element
minOccurs Optional. Specifies the minimum number of times this element can occur in the parent element. The value can be any number >= 0. Default value is 1. This attribute cannot be used if the parent element is the schema element
nillable Optional. Specifies whether an explicit null value can be assigned to the element. True enables an instance of the element to have the null attribute set to true. The null attribute is defined as part of the XML Schema namespace for instances. Default is false
abstract Optional. Specifies whether the element can be used in an instance document. True indicates that the element cannot appear in the instance document. Instead, another element whose substitutionGroup attribute contains the qualified name (QName) of this element must appear in this element's place. Default is false
block Optional. Prevents an element with a specified type of derivation from being used in place of this element. This value can contain #all or a list that is a subset of extension, restriction, or equivClass:
  • extension - prevents elements derived by extension
  • restriction - prevents elements derived by restriction
  • substitution - prevents elements derived by substitution
  • #all - prevents all derived elements
final Optional. Sets the default value of the final attribute on the element element.  This attribute cannot be used if the parent element is not the schema element. This value can contain #all or a list that is a subset of extension or restriction:
  • extension - prevents elements derived by extension
  • restriction - prevents elements derived by restriction
  • #all - prevents all derived elements
any attributes Optional. Specifies any other attributes with non-schema namespace

Ejemplo 1

El siguiente ejemplo es un esquema con cuatro elementos simples llamados "fname", "lname", "age" y "dateborn", que son de tipo cadena, nonNegativeInteger y date:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="fname" type="xs:string"/>
<xs:element name="lname" type="xs:string"/>
<xs:element name="age" type="xs:nonNegativeInteger"/>
<xs:element name="dateborn" type="xs:date"/>

</xs:schema>

Ejemplo 2

El siguiente ejemplo es un esquema con un elemento llamado "nota" que es de tipo complejo. El elemento "nota" contiene otros cuatro elementos simples; "a", "desde", "título" y "cuerpo":

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element name="to" type="xs:string"/>
      <xs:element name="from" type="xs:string"/>
      <xs:element name="heading" type="xs:string"/>
      <xs:element name="body" type="xs:string"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

</xs:schema>

Ejemplo 3

Este ejemplo es bastante igual al Ejemplo 2, pero aquí hemos elegido usar el atributo ref para referirnos a los nombres de los elementos:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">

<xs:element name="note">
  <xs:complexType>
    <xs:sequence>
      <xs:element ref="to"/>
      <xs:element ref="from"/>
      <xs:element ref="heading"/>
      <xs:element ref="body"/>
    </xs:sequence>
  </xs:complexType>
</xs:element>

<xs:element name="to" type="xs:string"/>
<xs:element name="from" type="xs:string"/>
<xs:element name="heading" type="xs:string"/>
<xs:element name="body" type="xs:string"/>

</xs:schema>

❮ Referencia completa del esquema XML