XSD元素的简单说明

80酷酷网    80kuku.com

  <!--[if !supportLists]-->²       <!--[endif]-->XSD 元素

:声明一个元素。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

     <element

  abstract = Boolean : false

  block = (#all | List of (extension | restriction | substitution))

  default = string

  final = (#all | List of (extension | restriction))

  fixed = string

  form = (qualified | unqualified)

  id = ID

  maxOccurs = (nonNegativeInteger | unbounded) : 1

  minOccurs = nonNegativeInteger : 1

  name = NCName

  nillable = Boolean : false

  ref = QName

  substitutionGroup = QName

  type = QName

{any attributes with non-schema Namespace}...>

Content: (annotation?, ((simpleType | complexType)?, (unique | key | keyref)*))

</element>

<!--[if !supportLists]-->2、         <!--[endif]-->block:

导出类型,该元素是为了防止具有指定导出类型的元素被用于替代该元素。其值可能为:

extension: 防止通过扩展导出的元素替换该元素。

restriction: 防止通过限制导出的元素替换该元素。

substitution:防止通过替换导出的元素替换该元素。

#all:防止所有的类型的导出元素替换该元素。

<!--[if !supportLists]-->3、         <!--[endif]-->default:

如果该元素为简单类型或者为textOnly的话,设置该元素的缺省值。default与fixed冲突。substitutionGroup:可用来替换该元素的元素的名称。该元素必须具有相同的类型后者具有从指定元素导出的类型。

如果引用的元素是在全局级别声明的(父元素是 schema 元素),则可以在任何元素上使用该属性。

类似与程序设计中的缺省值。

该值必须是 QName。

<!--[if !supportLists]-->4、         <!--[endif]-->final:

导出类型。可以为extension,restriction以及#all,仅仅作用于包含元素为schema的元素。

<!--[if !supportLists]-->5、         <!--[endif]-->fixed:

如果该元素是简单的或者为textOnly的元素的话,那么它的值是预定的不可更改的,可以使用fixed设置这个值,。fixed与default矛盾。它类似于程序设计中的const的作用。

<!--[if !supportLists]-->6、         <!--[endif]-->form:

元素的形式,是否通过命名空间前缀的限定。可选值有qualified与unqualified

<!--[if !supportLists]-->7、         <!--[endif]-->id

<!--[if !supportLists]-->8、         <!--[endif]-->maxOccurse、minOccurse

最多最少出现的次数。最大值为无限制”unbounded”,包含元素为”schema”的元素则自动禁止。

<!--[if !supportLists]-->9、         <!--[endif]-->name:

名称,为无冒号名称(NCName),如果包含元素为”Schema”的话,则必须具有。

<!--[if !supportLists]-->10、     <!--[endif]-->nillable:

显示指示是否可以付空值给这个元素。默认为false

<!--[if !supportLists]-->11、     <!--[endif]-->ref:

在此架构声明的元素,这个名称必须为该Schema中另一个Element的QName。如果包含元素为schema,则自动禁止。complexType、simpleType、key、keyref 和 unique 元素以及 nillable、default、fixed、form、block 和 type 属性不能出现。

<!--[if !supportLists]-->12、     <!--[endif]-->type:

该元素的数据类型,可以为内置类型以及simplyType、complexType的名称,type与ref不能够同时出现。

 

<!--[if !supportLists]-->13、     <!--[endif]-->元素信息:

出现次数:定义

父元素:schema、choice、all、sequence

内容:simplyType、complexType、key、keyRef、unique

<!--[if !supportLists]-->14、     <!--[endif]-->备注:

只有在 ref 和 type 属性均不存在时,simpleType 或 complexType 元素才可以作为子元素存在。此外,元素可以通过在 choice、all、sequence 和 complexType 元素内的引用出现。头元素声明必须直接定义复杂类型。

 

<!--[if !supportLists]-->二、<!--[endif]-->Attribute:声明一个属性。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<attribute

default = string

fixed = string

form = (qualified | unqualified)

id = ID

name = NCName

ref = QName

type = QName

use = (optional | prohibited | required): optional

{any attributes with non-schema Namespace...}>

Content: (annotation, (simpleType))

</attribute>

其中的部分属性说明:

<!--[if !supportLists]-->2、         <!--[endif]-->use:

一个指示符,指示如何使用该元素。可选值如下:

<!--[if !supportLists]-->3、         <!--[endif]-->optional:

属性可选的,并且可以具备任何值,这是默认值。

<!--[if !supportLists]-->4、         <!--[endif]-->prohibited:

不能够使用该属性,该属性用于其他复杂类型的限制中以禁止使用现有属性。也就是说它仅仅可以出现在restriction下面的属性中。

<!--[if !supportLists]-->5、         <!--[endif]-->required:

属性必须出现一次,可以使用该属性声明数据类型中的任何值。它的使用方法同prohibition,如果该属性声明为全局属性(其父元素为schema)的话,则该框架中的所有元素都需要该属性。

<!--[if !supportLists]-->6、         <!--[endif]-->元素信息

出现次数: 在 schema 元素中定义一次。在复杂类型或属性组中引用多次。

父元素: attributeGroup、schema、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)

内容:annotation、simpleType

 

 

<!--[if !supportLists]-->三、<!--[endif]-->attributeGroup:将一组属性声明归为一组,以便为复杂类型定义将它们并为一个组。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<attributeGroup

id = ID

name = NCName

ref = QName

{any attributes with non-schema Namespace...}>

Content: (annotation?), ((attribute | attributeGroup)*, anyAttribute?))

</attributeGroup>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息:

出现次数: 无限制

父元素: attributeGroup、complexType、schema、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)

内容: annotation、attribute、attributeGroup、anyAttribute

 

<!--[if !supportLists]-->四、<!--[endif]-->anyAttribute:使来自指定命名空间的任何属性可以显示在包含 complexType 元素或包含 attributeGroup 元素中。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<anyAttribute

id = ID

namespace = ((##any | ##other) | List of (anyURI | (##targetNamespace | ##local))) : ##any

processContents = (lax | skip | strict): strict

{any attributes with non-schema Namespace...}>

Content: (annotation?)

</anyAttribute>

部分属性说明如下:

<!--[if !supportLists]-->2、         <!--[endif]-->processContents :

一个指示器,指示应用程序或 XML 处理器应如何根据由该 anyAttribute 元素指定的属性处理 XML 文档的验证。

如果没有指定 processContents 属性,则默认为 strict。如果指定了 processContents,它必须是以下值之一。

Strict: XML处理器必须获得所需命名空间的架构,并且必须验证来自这些命名空间的所有属性。

Lax:XML处理器尝试获取所需命名空间的架构,并尝试验证来自这些命名空间的所有属性;但是,即使不能获取该架构,也不会发生任何错误。

Skip: XML 处理器不尝试验证来自指定命名空间的任何属性。

<!--[if !supportLists]-->3、         <!--[endif]-->元素信息:

出现次数 无限制

父元素 complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)、attributeGroup

内容 annotation

 

<!--[if !supportLists]-->五、<!--[endif]-->simplyType:定义一个简单类型,它确定具有纯文本属性或者元素的值有关的信息以及对它们的约束。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<simpleType

final = (#all | (list | union | restriction))

id = ID

name = NCName

{any attributes with non-schema Namespace}...>

Content: (annotation?, (restriction | list | union))

</simpleType>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息

出现次数 无限制

父元素 attribute、element、list、restriction (simpleType)、schema、union

内容 annotation、list、restriction (simpleType)、union

 

 

<!--[if !supportLists]-->六、<!--[endif]-->complexType:定义一个复杂内容的元素,它确定属性集及元素内容。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<complexType

abstract = Boolean : false

block = (#all | List of (extension | restriction))

final = (#all | List of (extension | restriction))

id = ID

mixed = Boolean : false

name = NCName

{any attributes with non-schema Namespace...}>

Content: (annotation?, (simpleContent | complexContent | ((group | all |

choice | sequence)?, ((attribute | attributeGroup)*, anyAttribute?))))

</complexType>

部分属性说明如下:

<!--[if !supportLists]-->2、         <!--[endif]-->mixed :

一个指示符,指示是否允许字符数据出现在该复杂类型的子元素之间。默认值为 false。

如果 simpleContent 元素是子元素,则不允许 mixed 属性。

如果 complexContent 元素是子元素,则该 mixed 元素可被 complexContent 元素的 mixed 属性重写。

可选。 ????           

<!--[if !supportLists]-->3、         <!--[endif]-->元素信息:

出现次数 在架构内为无限制;在元素内为一次。

父元素 element、redefine、schema

内容 annotation、simpleContent、complexContent、group、all、choice、sequence、attribute、attributeGroup、anyAttribute

<!--[if !supportLists]-->4、         <!--[endif]-->备注:

复杂类型实质上是对可以包含属性和元素的元素的类型定义。一个元素可以由引用 complexType 元素(定义该元素的结构、内容和属性)的 type 属性声明。(一个元素还可以在其 type 属性中接受对 simpleType 的引用。)

一个复杂类型可以包含以下元素中的一个元素且只能包含一个元素,该元素确定在复杂类型中允许的内容类型。

simpleContent 该复杂类型具有字符数据或将 simpleType 作为内容并且不包含任何元素,但可以包含属性。

complexContent 该复杂类型只包含元素或不包含任何元素内容(空)。

group 该复杂类型包含在引用组中定义的元素。

sequence 该复杂类型包含在指定序列中定义的元素。

choice 该复杂类型允许在选项元素中指定的元素之一。

all 该复杂类型允许在所有元素中指定的任意或所有元素出现一次。

如果 group、sequence、choice 或 all 被指定为子元素,则可以选择使用以下元素声明 complexType 的属性。

attribute 该复杂类型包含指定的属性。

attributeGroup 该复杂类型包含在引用的 attributeGroup 中定义的属性。

anyAttribute 该复杂类型可以包含来自指定命名空间的任何属性。

可以使用任何数目的 attribute 或 attributeGroup 元素。还可以使用 anyAttribute 的一个实例。

如果指定 group、sequence、choice 或 all,则元素必须按以下顺序出现。

group | sequence | choice | all

attribute | attributeGroup

anyAttribute

<!--[if !supportLists]-->七、<!--[endif]-->simplyContent:包含对 complexType 元素(它以字符数据或 simpleType 元素为内容)的扩展或限制并且不包含任何元素。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

    <simpleContent

  id = ID

  {any attributes with non-schema Namespace}...>

Content: (annotation?, (restriction | extension))

</simpleContent>

<!--[if !supportLists]-->八、<!--[endif]-->complexContent:包含对仅包含混合内容或元素的复杂类型的扩展或限制。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<complexContent

id = ID

mixed = Boolean

{any attributes with non-schema Namespace}...>

Content: (annotation?,  (restriction | extension))

</complexContent>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息:

出现次数 一次

父元素 complexType

内容 可选。annotation

必选。以下元素中的一个且只能是一个:restriction (complexContent) 或 extension (complexContent)。

 

元素集合方式元素声明:

<!--[if !supportLists]-->九、<!--[endif]-->all:允许组中的元素以任意元素显示(或不显示在)在包含元素中。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<all

id = ID

maxOccurs= 1: 1

minOccurs= (0 | 1): 1

{any attributes with non-schema Namespace...}>

Content: (annotation?, element*)

</all>

<!--[if !supportLists]-->十、<!--[endif]-->sequence:要求组中的元素以指定的顺序出现在包含元素中

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<sequence

id = ID

maxOccurs = (nonNegativeInteger | unbounded) : 1

minOccurs = nonNegativeInteger : 1

{any attributes with non-schema Namespace}...>

Content: (annotation?, (element | group | choice | sequence | any)*)

</sequence>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息:

出现次数: 在组内为一次;否则为无限制。

父元素:  group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)

内容: annotation、any、choice、element、group、sequence

 

<!--[if !supportLists]-->十一、       <!--[endif]-->choince:允许且仅允许选定组中包含的一个元素出现在包含元素中。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<choice

id = ID

maxOccurs= (nonNegativeInteger | unbounded) : 1

minOccurs= nonNegativeInteger : 1

{any attributes with non-schema Namespace}...>

Content: (annotation?, (element | group | choice | sequence | any)*)

</choice>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息:

出现次数: 在 group 和 complexType 元素中为一次;其他为无限制。

父元素: group、choice、sequence、complexType、restriction (simpleContent)、extension (simpleContent)、restriction (complexContent)、extension (complexContent)

内容: annotation、any、choice、element、group、sequence

 

扩展元素说明:

<!--[if !supportLists]-->十二、       <!--[endif]-->extension(simplyContent):包含对 simpleContent 的扩展。通过添加指定属性、属性组或 anyAttribute,扩展了简单类型或具有简单         内容的复杂类型,类似程序设计中的继承。

<!--[if !supportLists]-->1、         <!--[endif]-->方式:

<extension

base = QName

id = ID

{any attributes with non-schema Namespace}...>

Content: (annotation?, ((attribute | attributeGroup)*, anyAttribute?))

</extension>

<!--[if !supportLists]-->2、         <!--[endif]-->信息:

出现次数: 一次

父元素: simpleContent

内容: annotation、attribute、attributeGroup、anyAttribute

<!--[if !supportLists]-->十三、       <!--[endif]-->extension(complexContent):包含对 complexContent 的扩展。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<extension

base = QName

id = ID

{any attributes with non-schema Namespace}...>

Content: (annotation?, ((group | all | choice | sequence)?, ((attribute |

attributeGroup)*, anyAttribute?)))

</extension>

<!--[if !supportLists]-->2、         <!--[endif]-->元素信息:

出现次数: 一次

父元素: complexContent

内容: annotation、attribute、attributeGroup、anyAttribute、choice、all、sequence、group

 

约束元素列表:

<!--[if !supportLists]-->十四、       <!--[endif]-->restriction(simplyType):定义对 simpleType 定义的约束。

<!--[if !supportLists]-->1、         <!--[endif]-->方式:

<restriction

base = QName

id = ID

{any attributes with non-schema Namespace}...>

Content: (annotation?, (simpleType?, (minExclusive | minInclusive | maxExclusive | maxInclusive | totalDigits |fractionDigits | length | minLength | maxLength | enumeration | whiteSpace | pattern)*))

</restriction>

<!--[if !supportLists]-->十五、       <!--[endif]-->restriction (simplyContent):定义对 simpleContent 定义的约束。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<restriction

base = QName

id = ID

{any attributes with non-schema Namespace}...>

Content: (annotation?, (simpleType?, (minExclusive | minInclusive |

maxExclusive | maxInclusive | totalDigits |fractionDigits | length |

minLength | maxLength | enumeration | whiteSpace | pattern)*)?,

((attribute | attributeGroup)*, anyAttribute?))

</restriction>

<!--[if !supportLists]-->十六、       <!--[endif]-->restriction(complexContent):定义对complexContent定义的约束。

<!--[if !supportLists]-->1、         <!--[endif]-->声明方式:

<restriction

base = QName

id = ID

{any attributes with non-schema Namespace}...>

Content: (annotation?, (group | all | choice | sequence)?, ((attribute |

attributeGroup)*, anyAttribute?))

</restriction>


分享到
  • 微信分享
  • 新浪微博
  • QQ好友
  • QQ空间
点击: