DTD - 属性
来源:互联网 发布:js获取表格一行数据 编辑:程序博客网 时间:2024/04/29 18:02
In a DTD, Attributes are declared with an ATTLIST declaration.
在DTD中,属性是通过ATTLIST声明来声明的。
Declaring Attributes
声明属性
An attribute declaration has the following syntax:
属性声明的语法如下:
<!ATTLIST element-name attribute-name
attribute-type default-value>
example:
DTD example:
<!ATTLIST payment type CDATA "check">
XML example:
<payment type="check" />
The attribute-type can have the following values:
属性类型含有以下值:
值
解释
CDATA
The value is character data
字符数据值
(en1|en2|..)
The value must be one from an enumerated list
必须是来自列表中的一个值
ID
The value is a unique id
唯一独立的id值
IDREF
The value is the id of another element
其它元素的id值
IDREFS
The value is a list of other ids
其它id的列表值
NMTOKEN
The value is a valid XML name
其值为一个有效的XML名称
NMTOKENS
The value is a list of valid XML names
其值为一组有效的XML名称列表值
ENTITY
The value is an entity
其值为一个实体
ENTITIES
The value is a list of entities
其值为一组实体的列表
NOTATION
The value is a name of a notation
其值为一个符号的名称
xml:
The value is a predefined xml value
预定的XML值
The default-value can have the following values:
省略补充含有以下值:
值
解释
value
The default value of the attribute
属性默认值
#REQUIRED
The attribute value must be included in the element
包含于元素内的属性值
#IMPLIED
The attribute does not have to be included
可包含也可不包含于元素内
#FIXED value
The attribute value is fixed
固定的属性值
Specifying a Default attribute value
指定一个默认的属性值
DTD:
<!ELEMENT square EMPTY>
<!ATTLIST square width CDATA "0">
Valid XML:
<square width="100" />
In the example above, the "square" element is defined to be an empty element with a "width" attribute of type CDATA. If no width is specified, it has a default value of 0.
在上面的例子中,"square"元素定义为含有CDATA类型的"width"属性的空元素。如果没有指定width值,那它默认为0。
#IMPLIED
Syntax
语法
<!ATTLIST element-name attribute-name
attribute-type #IMPLIED>
Example
例子
DTD:
<!ATTLIST contact fax CDATA #IMPLIED>
Valid XML:
<contact fax="555-667788" />
Valid XML:
<contact />
Use the #IMPLIED keyword if you don't want to force the author to include an attribute, and you don't have an option for a default value.
如果你不想让author元素包含一个属性值或对默认值不具备选择权,那么你不妨使用#IMPLIED关键字。
#REQUIRED
Syntax
语法
<!ATTLIST element-name attribute_name
attribute-type #REQUIRED>
Example
例子
DTD:
<!ATTLIST person number CDATA #REQUIRED>
Valid XML:
<person number="5677" />
Invalid XML:
<person />
Use the #REQUIRED keyword if you don't have an option for a default value, but still want to force the attribute to be present.
如果你对默认值不具备选择权却想却有想让属性值存在,那么你不妨使用#REQUIRED关键字。
#FIXED
Syntax
语法
<!ATTLIST element-name attribute-name
attribute-type #FIXED "value">
Example
例子
DTD:
<!ATTLIST sender company CDATA #FIXED "Microsoft">
Valid XML:
<sender company="Microsoft" />
Invalid XML:
<sender company="W3Schools" />
Use the #FIXED keyword when you want an attribute to have a fixed value without allowing the author to change it. If an author includes another value, the XML parser will return an error.
当你希望属性是一个固定值且不希望让author元素去改变它,我们建议你使用#FIXED关键字。如果author包含另外一个值,XML剖析器将会提示错误。
Enumerated attribute values
列举属性值方法Enumerated attribute values:
Syntax:
<!ATTLIST element-name
attribute-name (en1|en2|..) default-value>
DTD example:
<!ATTLIST payment type (check|cash) "cash">
XML example:
<payment type="check" />
or
<payment type="cash" />
Use enumerated attribute values when you want the attribute values to be one of a fixed set of legal values.
当你希望得到一个固定合法的属性值时,请使用列举属性值(Enumerated attribute values)的方法。
- DTD - 属性
- DTD-属性
- DTD属性
- dtd属性
- DTD中的属性声明
- DTD 属性详解
- DTD的内部属性
- DTD的内部属性
- 4.DTD - 元素 - 属性
- DTD属性的定义
- dtd定义属性
- XML:DTD、DTD定义元素、DTD定义属性、DTD定义实体
- DTD中属性可使用类型列表
- XML----DTD-引用,验证,元素属性
- DTD、
- DTD
- DTD
- DTD
- 需要注意自动装拆箱的一个特例
- WINDOWS系统文件详解
- Oracle 11g new feature1
- 移动SI之MAS培训后一些总结
- CrystallReportViewer控件类常用属性与方法
- DTD - 属性
- 我爱娃娃
- 2007年步入社会的第一年,开始实习的第二天,留下我的第一篇Blog
- DTD - 实体
- asp过滤非法字符
- CSS定义
- DTD 校验
- 欢迎访问我的blog站点 www.cdot.net/blog
- 常见四种虚拟化技术优劣势对比