Element schematu XML
❮ Pełne odniesienie do schematu XML
Definicja i użycie
Element schematu definiuje element główny schematu.
Informacje o elemencie
- Elementy nadrzędne: BRAK
Składnia
<schema
id=ID
attributeFormDefault=qualified|unqualified
elementFormDefault=qualified|unqualified
blockDefault=(#all|list of (extension|restriction|substitution))
finalDefault=(#all|list of (extension|restriction|list|union))
targetNamespace=anyURI
version=token
xmlns=anyURI
any attributes
>
((include|import|redefine|annotation)*,(((simpleType|complexType|
group|attributeGroup)|element|attribute|notation),annotation*)*)
</schema>
Attribute | Description |
---|---|
id | Optional. Specifies a unique ID for the element |
attributeFormDefault | Optional. The form for attributes declared in the target namespace of this schema. The value must be "qualified" or "unqualified". Default is "unqualified". "unqualified" indicates that attributes from the target namespace are not required to be qualified with the namespace prefix. "qualified" indicates that attributes from the target namespace must be qualified with the namespace prefix |
elementFormDefault | Optional. The form for elements declared in the target namespace of this schema. The value must be "qualified" or "unqualified". Default is "unqualified". "unqualified" indicates that elements from the target namespace are not required to be qualified with the namespace prefix. "qualified" indicates that elements from the target namespace must be qualified with the namespace prefix |
blockDefault |
Optional. Specifies the default value of the block attribute on element and
complexType elements in the target namespace. The block attribute prevents a
complex type (or element) that has a specified type of derivation from being
used in place of this complex type. This value can contain #all or a list that
is a subset of extension, restriction, or substitution:
|
finalDefault |
Optional. Specifies the default value of the final attribute on element,
simpleType, and complexType elements in the target namespace. The final
attribute prevents a specified type of derivation of an element, simpleType, or
complexType element. For element and complexType elements, this value can
contain #all or a list that is a subset of extension or restriction. For
simpleType elements, this value can additionally contain list and union:
|
targetNamespace | Optional. A URI reference of the namespace of this schema |
version | Optional. Specifies the version of the schema |
xmlns | A URI reference that specifies one or more namespaces for use in this schema. If no prefix is assigned, the schema components of the namespace can be used with unqualified references |
any attributes | Optional. Specifies any other attributes with non-schema namespace |
Przykład 1
<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="values" type="xs:string" />
</xs:schema>
Przykład 2
W tym przykładzie składniki schematu (nazwa elementu, typ) w przestrzeni nazw http://www.w3.org/2001/XMLSchema są niekwalifikowane, a te dla https://www.w3schools.com/w3schoolsschema (mystring) są kwalifikowane z prefiksem wsc:
<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsc="https://www.w3schools.com/w3shoolsschema">
<element name="fname" type="wsc:mystring"/>
</schema>
❮ Pełne odniesienie do schematu XML