`
icz
  • 浏览: 7512 次
  • 来自: ...
最近访客 更多访客>>
社区版块
存档分类
最新评论

Old topic, DTD

    博客分类:
  • XML
阅读更多




? Zero or one of the element is allowed.

* Zero or more of the element is allowed.

+ One or more of the element is required.





In narrative documents, it's common for a single element to contain both child elements and un-marked up, nonwhitespace character data. For example, recall this definition element from Chapter 2:


 <definition>A <term>Turing Machine</term> refers to an abstract finite 

state automaton with infinite memory that can be proven equivalent 

to any any other finite state automaton with arbitrarily large memory. 

Thus what is true for one Turing machine is true for all Turing 

machines no matter how implemented.

</definition>




The definition element contains some nonwhitespace text and a term child. This is called mixed content. An element that contains mixed content is declared like this:



<!ELEMENT definition (#PCDATA | term)*>






If an element is empty, then it can contain nothing, not even whitespace.







There are 10 attribute types in XML. They are:

CDATA
NMTOKEN
NMTOKENS
Enumeration
ENTITY
ENTITIES
ID
IDREF
IDREFS
NOTATION

An ID type attribute must contain an XML name (not a name token but a name) that is unique within the XML document. More precisely, no other ID type attribute in the document can have the same value. (Attributes of non-ID type are not considered.) Each element may have no more than one ID type attribute.

As the keyword suggests, ID type attributes assign unique identifiers to elements. ID type attributes do not need to have the name "ID" or "id", although they very commonly do. For example, this ATTLIST declaration says that every employee element must have a social_security_number ID attribute:

<!ATTLIST employee social_security_number ID #REQUIRED>


ID numbers are tricky because a number is not an XML name and therefore not a legal XML ID. The normal solution is to prefix the values with an underscore or a common letter. For example:

<employee social_security_number="_078-05-1120"/>


In addition to providing a data type, each ATTLIST declaration includes a default declaration for that attribute. There are four possibilities for this default:


#IMPLIED

The attribute is optional. Each instance of the element may or may not provide a value for the attribute. No default value is provided.

#REQUIRED

The attribute is required. Each instance of the element must provide a value for the attribute. No default value is provided.

#FIXED

The attribute value is constant and immutable. This attribute has the specified value regardless of whether the attribute is explicitly noted on an individual instance of the element. If it is included, though, it must have the specified value.

Literal

The actual default value is given as a quoted string.

This ATTLIST declaration says that every web_page element has a protocol attribute. If a particular web_page element doesn't have an explicit protocol attribute, then the parser will supply one with the value http:

<!ATTLIST web_page protocol NMTOKEN "http">
分享到:
评论

相关推荐

    DTD 总结 DTD 总结 DTD 总结

    **DTD(Document Type Definition)**是XML文档类型定义的缩写,它是一种规范,用于定义XML文档的结构和限制。DTD允许我们为XML文档创建一套预定义的规则,确保文档内容遵循特定的格式,便于数据交换和处理。下面将...

    DTD 教程 DTD 实例

    **DTD(Document Type Definition)教程** DTD 是 XML(Extensible Markup Language)文档的结构定义工具,它用于描述 XML 文档的元素、属性、实体等结构,确保 XML 文档的合法性。DTD 的作用在于提供一种机制,使...

    使用DTD验证XML文档

    使用DTD验证XML文档 一、 DTD的定义: a) DTD是Document Type Defintion的缩写,即文档类型定义。DTD用来描述XML文档的结构。 二、 DTD可能包含的内容: a) 元素的定义规则。 b) 元素之间的关系规则。 c) 属性的定义...

    DTD的CHM帮助文档

    **DTD(Document Type Definition)** 是XML(Extensible Markup Language)文档类型定义的缩写,它是XML规范的一部分,用于定义XML文档的结构和元素。在XML文档中,DTD的作用是确保文档内容遵循预设的规则,即所有...

    mybatis-3-config.dtd mybatis-3-mapper.dtd

    在MyBatis中,`mybatis-3-config.dtd` 和 `mybatis-3-mapper.dtd` 是两个至关重要的DTD(Document Type Definition)文件,它们定义了MyBatis配置文件和映射文件的结构和规则。 首先,让我们深入了解一下`mybatis-3...

    ant_DTD.dtd

    ant_DTD.dtd 已生成好

    DTD验证XML详解

    DTD(Document Type Definition)是XML的一个重要组成部分,它定义了XML文档的结构和规则,确保XML文档的一致性和合法性。本文将深入探讨DTD验证XML的概念、原理以及如何进行实践操作。 XML文档通过DTD来规定其元素...

    xml与DTD,xml与DTD

    ### XML与DTD详解 #### 一、XML简介 XML(Extensible Markup Language)是一种非常重要的数据交换标准,它被广泛应用于互联网数据交换场景之中。XML的设计初衷是为了传输和存储数据,其灵活性允许用户自定义标签,...

    XML中的外部dtd和内部dtd实例

    在XML中,DTD(Document Type Definition)是用来定义XML文档结构的规范,它规定了元素、属性以及它们之间的关系。理解XML的外部DTD和内部DTD对于编写符合规范的XML文档至关重要。 一、XML DTD概述 DTD是一种元语言...

    不同版本的 struts2.dtd

    在Struts2中,DTD(Document Type Definition)文件扮演着重要的角色,它定义了配置文件的结构和规则。下面我们将详细探讨不同版本的Struts2 DTD及其相关知识点。 1. **Struts2 DTD 的作用** - Struts2 DTD 是XML...

    sql-map-2.dtd和sql-map-config-2.dtd

    本文将深入探讨与“sql-map-2.dtd”和“sql-map-config-2.dtd”相关的知识点,以及它们在Ibatis中的作用。 Ibatis是一个轻量级的ORM(对象关系映射)框架,它允许开发者将SQL语句直接写在配置文件中,通过XML映射...

    mybatis的两个Dtd文件,config.dtd mapper.dtd

    DTD(Document Type Definition)是XML文档类型定义,它是XML的一种规范,用于定义XML文档的结构和元素。在MyBatis中,DTD文件用于验证配置文件的正确性,确保XML文件符合特定的格式。 1. **config.dtd文件** `...

    将DTD与XML文档相关联之外部DTD

    在XML(可扩展标记语言)文档中,DTD(文档类型定义)是一种重要的元数据,用于定义文档结构和元素规则。DTD允许我们规范XML文件的结构,确保数据的准确性和一致性。本文将深入探讨如何通过外部DTD将DTD文件与XML...

    DTD的定义、规则和编写

    ### DTD的定义、规则和编写 #### 一、DTD概述 **文档类型定义**(Document Type Definition, DTD)是一套关于标记语言的语法规则,主要用于定义XML文档的结构和内容。DTD作为XML 1.0规范的一部分,是XML文件验证的...

    mybatis-3-config/mapper.dtd 解决mybatis头文件报错

    然后打开eclipse -&gt;Window-&gt;prefenrence-&gt;XML-&gt;XML Catalog-&gt;User Specifiled Entreis-&gt;Add-&gt;Location(此处是你放dtd文件的位置例如:‪D:\mybatis\mybatis-3-config.dtd)-&gt;Key(如果更改config,此处应该是:-//...

    几个常用的DTD

    DTD,全称Document Type Definition,是XML文档类型定义的缩写。它是一种规范,用于定义XML文档的结构和元素,确保文档内容遵循特定的规则,从而使得数据具有语义和一致性。DTD通常由一系列声明组成,包括元素声明、...

Global site tag (gtag.js) - Google Analytics