当前位置: 首页 > 网络学院 > XML相关教程 > Schema (XSD) > XML schema 元素

Schema (XSD)
Schema (XSD) 介绍
为何使用 XML Schemas?
如何定制 XSD
XSD - <schema>元素
XSD 简单元素
XSD 属性
XSD 约束面
XSD 复合元素
XSD 复合空元素
XSD 复合纯元素
XSD 复合纯文本
XSD 混合内容的复合类型
XSD 指示器复合类型
XSD <any> 元素
XSD <anyAttribute> 元素
XSD 元素替代
XSD 实例
XSD 字符串数据类型
XSD 日期数据类型
XSD 小数数据类型

Schema (XSD) 中的 XML schema 元素


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 356 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The schema element defines the root element of a schema.
schema元素的作用是:定义一个schema元素的根元素。

Element Information
元素信息

  • Parent elements: NONE
    父元素:无

Syntax
语法

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

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
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
可选参数。指定在当前schema元素的目标命名空间中声明的属性格式。这个值必须是“qualified已授权”或“unqualified未授权”。默认值是“未授权”。“未授权”指明了来自于目标命名空间的属性不允许拥有命名空间的前缀资格;“已授权”指明了来自于目标命名空间的属性允许拥有命名空间的前缀资格
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
可选参数。指定在当前schema元素的目标命名空间中声明的元素格式。这个值必须是“qualified已授权”或“unqualified未授权”。默认值是“未授权”。“未授权”指明了来自于目标命名空间的元素不允许拥有命名空间的前缀资格;“已授权”指明了来自于目标命名空间的元素允许拥有命名空间的前缀资格
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:

可选参数。指定元素中block属性的默认值以及目标命名空间中的complexType[复合类型]元素。该block属性禁止包含指定到处类型的复合类型(或元素)由于替代当前的复合类型。这个值可以包含#all,或者是extension[扩展类型]、restriction[限制类型]或substitution[替代类型]的列表:

  • extension - prevents complex types derived by extension
    扩展类型 - 禁止使用通过扩展类型导出的复合类型
  • restriction - prevents complex types derived by restriction
    限制类型 - 禁止使用通过限制类型导出的复合类型
  • substitution - prevents substitution of elements
    substitution - 禁止使用元素替代
  • #all - prevents all derived complex types
    #all - 禁止使用上述三者
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:

可选参数。指定目标命名空间中element[元素]、simpleType[简单类型]元素以及complexType[复合类型]元素的final 属性值。final属性禁止指定element[元素]、simpleType[简单类型]元素以及complexType[复合类型]元素的导出类型。这个值可以包含#all、list[列表属性]和union[联合属性],或者是extension[扩展类型]和restriction[限制类型]的子集列表:

  • extension - prevents derivation by extension
    extension - 禁止使用通过扩展属性导出的类型
  • restriction - prevents derivation by restriction
    restriction - 禁止使用通过限制属性导出的类型
  • list - prevents derivation by list
    list - 禁止使用通过列表属性导出的类型
  • union - prevents derivation by union
    union - 禁止使用通过联合属性导出的类型
  • #all - prevents all derivation
    #all - 禁止使用上述的所有属性
targetNamespace Optional. A URI reference of the namespace of this schema
可选参数。指定当前schema命名空间的URI参数
version Optional. Specifies the version of the schema
可选参数。指定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
指定一个URI参数,该参数为当前schema元素的使用指定了一个或多个命名空间。如果未指定前缀,那么命名空间的schema组件可以与未授权的参数一起使用
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定其它的属性(这些属性无schema命名空间)

Example 1
案例1

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

Example 2
案例2

In this example, the schema components (element name, type) in the http://www.w3.org/2001/XMLSchema namespace are unqualified and those for http://www.w3schools.com/w3schoolsschema (mystring) are qualified with the wsc prefix:
在这个案例中,schema组件(元素名称、类型)未在http://www.w3.org/2001/XMLSchema namespace中定义,然而这些组件在http://www.w3schools.com/w3schoolsschema (mystring)已获取wsc前缀资格:

<?xml version="1.0"?>
<schema xmlns="http://www.w3.org/2001/XMLSchema"
xmlns:wsc="http://www.w3schools.com/w3shoolsschema">
<element name="fname" type="wsc:mystring"/>
</schema>

评论 (0) All

登陆 | 还没注册?