Výukový program XML

XML HOME Úvod do XML XML Jak používat XML strom Syntaxe XML Prvky XML Atributy XML Jmenné prostory XML Zobrazení XML XML HttpRequest XML Parser XML DOM XML XPath XML XSLT XML XQuery XML XLlink XML Validator XML DTD Schéma XML XML server Příklady XML XML kvíz XML certifikát

XML AJAX

Úvod do AJAX AJAX XMLHttp Požadavek AJAX Odpověď AJAX Soubor XML AJAX AJAX PHP AJAX ASP Databáze AJAX Aplikace AJAX Příklady AJAX

XML DOM

Úvod do DOM DOM uzly Přístup k DOM Informace o uzlu DOM Seznam uzlů DOM DOM Traversing Navigace DOM DOM získat hodnoty DOM změnit uzly DOM Remove Nodes DOM nahradit uzly DOM Vytvořte uzly DOM Přidat uzly Klonovací uzly DOM Příklady DOM

Výukový program XPath

Úvod do XPath Uzly XPath Syntaxe XPath osy XPath Operátoři XPath Příklady XPath

Kurz XSLT

Úvod do XSLT Jazyky XSL Transformace XSLT XSLT <šablona> XSLT <hodnota-of> XSLT <pro každého> XSLT <sort> XSLT <if> XSLT <vyberte> Použít XSLT XSLT u klienta XSLT na serveru XSLT Úprava XML Příklady XSLT

Výukový program XQuery

Úvod do XQuery Příklad XQuery XQuery FLWOR HTML XQuery Podmínky XQuery Syntaxe XQuery Přidat XQuery XQuery Select Funkce XQuery

XML DTD

Úvod do DTD Stavební bloky DTD DTD prvky Atributy DTD DTD Elements vs Attr DTD entity Příklady DTD

XSD schéma

Úvod do XSD XSD Jak na to XSD <schéma> XSD prvky XSD atributy Omezení XSD

XSD komplex

XSD prvky XSD Prázdné Pouze prvky XSD Pouze text XSD XSD smíšené XSD indikátory XSD <libovolné> XSD <jakýkoliAtribut> Náhrada XSD Příklad XSD

XSD data

XSD řetězec Datum XSD Číselné XSD XSD Různé XSD reference

Webové služby

Služby XML XML WSDL XML SOAP XML RDF XML RSS

Reference

Typy uzlů DOM Uzel DOM DOM NodeList DOM NamedNodeMap Dokument DOM Prvek DOM Atribut DOM Text DOM DOM CDATA Komentář DOM DOM XMLHttpRequest DOM Parser Prvky XSLT Funkce XSLT/XPath

Prvek prvku schématu XML


❮ Vyplňte odkaz na schéma XML

Definice a použití

Element element definuje element.

Informace o prvku

  • Nadřazené prvky: schéma, výběr, vše, posloupnost, skupina

Syntax

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

(Znak ? deklaruje, že prvek se může vyskytovat nula nebo jednou, a znak * deklaruje, že prvek se uvnitř prvku prvku může vyskytovat nula nebo vícekrát)

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

Příklad 1

Následující příklad je schéma se čtyřmi jednoduchými prvky pojmenovanými „fname“, „lname“, „age“ a „dateborn“, které jsou typu string, nonNegativeInteger a 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>

Příklad 2

Následující příklad je schéma s prvkem s názvem „note“, který je komplexního typu. Prvek „note“ obsahuje další čtyři jednoduché prvky; "do", "od", "nadpis" a "tělo":

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

Příklad 3

Tento příklad je zcela shodný s příkladem 2, ale zde jsme se rozhodli použít atribut ref k odkazování na názvy prvků:

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

❮ Vyplňte odkaz na schéma XML