Учебник по XML

XML ГЛАВНАЯ Введение в XML XML Как использовать XML-дерево Синтаксис XML XML-элементы XML-атрибуты Пространства имен XML Отображение XML XML HttpRequest XML-парсер XML DOM XML XPath XML XSLT XML XQuery XML-ссылка XML-валидатор XML-DTD XML-схема XML-сервер XML-примеры XML-викторина XML-сертификат

XML АЯКС

Введение в АЯКС AJAX XMLHttp АЯКС-запрос AJAX-ответ XML-файл AJAX АЯКС PHP АЯКС АСП База данных AJAX AJAX-приложения Примеры AJAX

XML DOM

Введение в ДОМ DOM-узлы Доступ к DOM Информация об узле DOM Список узлов DOM Обход DOM DOM-навигация DOM Получить значения Узлы изменения DOM DOM Удалить узлы DOM заменить узлы DOM Создание узлов DOM Добавить узлы Узлы клонирования DOM Примеры DOM

Учебник XPath

XPath Введение Узлы XPath Синтаксис XPath Оси XPath Операторы XPath Примеры XPath

XSLT- учебник

Введение в XSLT Языки XSL XSLT-преобразование XSLT <шаблон> XSLT <значение> XSLT <для каждого> XSLT <сортировка> XSLT <если> XSLT <выбрать> XSLT Применить XSLT на клиенте XSLT на сервере XSLT Редактировать XML XSLT-примеры

Учебник по XQuery

Введение в XQuery Пример XQuery XQuery FLWOR XQuery HTML Условия XQuery Синтаксис XQuery XQuery Добавить Выбор XQuery Функции XQuery

XML -DTD

Введение в DTD Строительные блоки DTD Элементы DTD Атрибуты DTD Элементы DTD и Attr Сущности DTD Примеры DTD

XSD- схема

Введение в XSD XSD Как XSD <схема> XSD-элементы XSD-атрибуты XSD-ограничения

Комплекс XSD

XSD-элементы XSD пустой Только элементы XSD Только текст XSD XSD смешанный XSD-индикаторы XSD <любой> XSD <любой атрибут> Замена XSD Пример XSD

XSD- данные

XSD-строка XSD-дата XSD числовой XSD Разное Справочник по XSD

Веб- сервисы

XML-сервисы XML WSDL XML-МЫЛО XML RDF XML RSS

использованная литература

Типы узлов DOM DOM-узел Список узлов DOM DOM NamedNodeMap Документ DOM DOM-элемент Атрибут DOM DOM-текст ДОМ CDATA Дом Комментарий DOM XMLHttpRequest Парсер DOM XSLT-элементы Функции XSLT/XPath

Элемент XML-схемы Элемент


❮ Полный справочник по XML-схеме

Определение и использование

Элемент element определяет элемент.

Информация об элементе

  • Родительские элементы: схема, выбор, все, последовательность, группа

Синтаксис

<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>

(Знак ? указывает, что элемент может встречаться ноль или один раз, а знак * объявляет, что элемент может встречаться ноль или более раз внутри элемента element)

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

Пример 1

Следующий пример представляет собой схему с четырьмя простыми элементами с именами «fname», «lname», «age» и «dateborn», которые имеют тип string, nonNegativeInteger и дату:

<?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>

Пример 2

В следующем примере представлена ​​схема с элементом с именем «заметка», который имеет сложный тип. Элемент «заметка» содержит четыре других простых элемента; «Кому», «От», «Заголовок» и «Тело»:

<?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>

Пример 3

Этот пример полностью аналогичен примеру 2, но здесь мы решили использовать атрибут ref для ссылки на имена элементов:

<?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>

❮ Полный справочник по XML-схеме