XML Schema schema 元素

定义和用法

schema 元素定义 schema 的根元素。

元素信息

出现次数 一次
父元素 (无父元素)
内容 include、import、annotation、redefine、attribute、attributeGroup、element、group、notation、simpleType、complexType

语法

<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
jegliche Attribute
>
((include|import|redefine|annotation)*,(((simpleType|complexType|
group|attributeGroup)|element|attribute|notation),annotation*)*)
<element name="fname" type="wsc:mystring"/>

Eigenschaft

id

Optional. Specifies the unique ID of the element.

attributeFormDefault

Optional. The form of the attribute declared in the target namespace of this schema. This value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified".

  • "unqualified" indicates that attributes in the target namespace do not need to be qualified with a namespace prefix.
  • "qualified" indicates that attributes in the target namespace must be qualified with a namespace prefix.

elementFormDefault

Optional. The form of the element declared in the target namespace of this schema. This value must be one of the following strings: "qualified" or "unqualified". The default value is "unqualified".

  • "unqualified" indicates that elements in the target namespace do not need to be qualified with a namespace prefix.
  • "qualified" indicates that elements in the target namespace must be qualified with a 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 complex types (or elements) with specified derived types from being used to replace inherited complex types (or elements). This value can include #all or a list, which is a subset of extension, restriction, or substitution:

  • extension - Prevents the replacement of complex types derived by extension from being used to replace this complex type.
  • restriction - Prevents the replacement of complex types derived by restriction from being used to replace this complex type.
  • substitution - Prevents the replacement of elements.
  • #all - Prevents all derived complex types from being used to replace this complex type.

finalDefault

Optional. Specifies the default value of the final attribute of element, simpleType, and complexType elements in the target namespace of this architecture. The final attribute prevents the specified derived type of element, simpleType, or complexType from being used to replace the complex type. For element and complexType elements, this value can include #all or a list, which is a subset of extension or restriction. For simpleType elements, the value can also include list and union:

  • extension - Standardmäßig können die Elemente in diesem Schema nicht durch Erweiterung abgeleitet werden. Gilt nur für element und complexType-Elemente.
  • restriction - Verhindert die Ableitung durch Beschränkung.
  • list - Verhindert die Ableitung durch Liste. Gilt nur für simpleType-Elemente.
  • union - Verhindert die Ableitung durch Union. Gilt nur für simpleType-Elemente.
  • #all - Standardmäßig können die Elemente in diesem Schema nicht durch irgendeine Methode abgeleitet werden.

targetNamespace

Die URI-Referenz des Namensraums dieses Schemas. Es kann auch ein Präfix für diesen Namensraum zugewiesen werden. Wenn kein Präfix zugewiesen ist, können die Schema-Komponenten dieses Namensraums mit nicht beschränkten Referenzen zusammen verwendet werden.

version

Optional. Definiert die Version des Schemas.

xmlns

Definiert eine oder mehrere Namensraum-URI-Referenzen, die in diesem Schema verwendet werden. Wenn kein Präfix zugewiesen ist, können die Schema-Komponenten dieses Namensraums mit nicht beschränkten Referenzen verwendet werden.

jegliche Attribute

Optional. Definiert jede andere Eigenschaft mit einem non-schema Namensraum.

Beispiel

Beispiel 1

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

Beispiel 2

In diesem Beispiel ist der Schema-Komponente (Elementname, Typ) in der Namensraum-URL http://www.w3.org/2001/XMLSchema nicht beschränkt, während http://www.codew3c.com/codew3cschema (mystring) durch den Präfix wsc beschränkt ist:

<?xml version="1.0"?>