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

Schema (XSD)
XSD 逻辑值数据类型
XML Schema总结
XML Schema 参考
XSD 验证

Schema (XSD) 中的 XML Schema simpleType 元素


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

Definition and Usage
定义和用法

The simpleType element defines a simple type and specifies the constraints and information about the values of attributes or text-only elements.
simpleType 元素的作用是:定义一个简单类型并指明属性值或文本元素值的限制类和信息。

Element Information
元素信息

  • Parent elements: attribute, element, list, restriction, schema, union
    父类信息:attribute[属性]、element[元素]、list[列表]、restriction[限制类]、schema、union[组合类]

Syntax
语法

<simpleType
id=ID
name=NCName
any attributes
>
(annotation?,(restriction|list|union))
</simpleType>

(The ? sign declares that the element can occur zero or one time inside the simpleType element)
“?”符号用于声明元素在simpleType元素中允许出现的次数(0次或1次)

属性 描述
id Optional. Specifies a unique ID for the element
可选参数。为元素指定一个独立的ID
name Specifies a name for the element. This attribute is required if the simpleType element is a child of the schema element, otherwise it is not allowed
可选参数。为元素指定一个名称。如果simpleType[简单类型]是schema元素的一个子类型,那么必须使用这个类型
any attributes Optional. Specifies any other attributes with non-schema namespace
可选参数。指定非schema命名空间的其它属性

Example 1
案例1

This example defines an element called "age" that is a simple type with a restriction. The value of age can NOT be lower than 0 or greater than 100:
这个案例定义了一个名为“age”的元素,该元素是一个包含restriction[限制属性]的简单类型。“age”的值不允许小于0或大于100:

<xs:element name="age"> <xs:simpleType> <xs:restriction base="xs:integer"> <xs:minInclusive value="0"/> <xs:maxInclusive value="100"/> </xs:restriction> </xs:simpleType>
</xs:element>

评论 (0) All

登陆 | 还没注册?