没有合适的资源?快使用搜索试试~ 我知道了~
首页C++专家指南:XML解析与应用
C++专家指南:XML解析与应用
需积分: 10 5 下载量 129 浏览量
更新于2024-07-27
收藏 1.09MB PDF 举报
《C++ XML:集成XML标准的力量与复杂性》是一本由Fabio Arciniegas编著的专业书籍,专为C++开发者设计,于2001年8月首次出版,由NewRidersPublishing发行。该书的ISBN号为0-7357-1052-X,共336页。此书的核心内容围绕如何在C++环境中有效地解析、处理和利用XML标准展开。 作者作为首席技术官,拥有丰富的C++和XML专业知识,他的公司postgraphy(<http://www.postgraphy.com/>)专注于视觉知识和图像处理应用的开发,这使得他在书中能够提供深入且实践经验丰富的指导。《C++ XML》覆盖了XML在数据表示和交换、行为理解和实现等方面的主要标准,如Expat、Xerces、Xalan、libxml2以及微软的MSXML等工具和库。 本书特别强调了使用C/C++解析器和工具包来构建应用程序和可重用框架,适用于各种XML应用场景,无论是作为数据格式还是用于构建复杂的系统交互。它不仅教授理论知识,还提供了实际案例分析和技术细节,帮助读者掌握从基础到高级的XML技术,无论是构建简单的XML解析程序,还是构建处理大型XML文档的高性能系统。 作为XML社区的活跃成员,Arciniegas的贡献包括C++实现的TREX语言和XLink软件,这表明他不仅是一名理论专家,也是一位实践者,他的经验无疑为读者提供了宝贵的洞见和最佳实践。 《C++ XML》是一本不可或缺的参考资料,对于希望深入理解并运用C++处理XML的开发者来说,无论是初学者还是进阶者,都能从中获益匪浅。它将理论与实践相结合,是提升C++开发者在XML领域技能的实用指南。
资源详情
资源推荐
<!ELEMENT description (#PCDATA | note | related)* >
<!ELEMENT note (#PCDATA | see)*>
<!ATTLIST episode
recorded CDATA #REQUIRED
aired CDATA #REQUIRED
rated (PG|PG13|R|NC17) #IMPLIED
key ID #REQUIRED>
<!ELEMENT see EMPTY>
<!ATTLIST see
also IDREF #REQUIRED>
<!ELEMENT related EMPTY>
<!ATTLIST related
terms NMTOKENS #REQUIRED>
<!ATTLIST description
official CDATA #FIXED "yes">
<!ATTLIST description
author CDATA #IMPLIED>
<!NOTATION ps SYSTEM "application/postscript"> <!-- a mime type -->
<!NOTATION gif PUBLIC
"-//Compuserve Information Services//NOTATION Graphics Interchange Format//EN">
<!-- a public id -->
<!ELEMENT graphic (#PCDATA)>
<!ATTLIST graphic
type NOTATION (ps | gif) "ps">
Listing 1.7 Valid Instance of the show Type
<?xml version="1.0"?>
<!DOCTYPE show SYSTEM "shows_1_2.dtd">
<show>
<name>
<!-- note that element names are case-sensitive -->
<simpleName>tymon thonpy</simpleName>
</name>
<episode recorded = "12/11/1971"
aired = "11/9/1972"
rated = "PG"
key = "mp-anagram">
<number>30</number>
<description author="Eric">A man who speaks only in anagrams
<note>Actually, they are only spoonerisms
<see also="mp-proust"/>
</note>.
</description>
</episode>
<episode recorded="4/24/1972"
aired="11/16/1972"
key="mp-proust">
<!-- The following element illustrates two things: default
attribute values (for attribute type) and how to embed
postscript in an XML document using notations. Naturally,
the technique can be extended to other types.
-->
<graphic>
/Times-Roman findfont
32 scalefont
setfont
100 200 translate
25 rotate
2 1 scale
newpath
0 0 moveto
(Hail Guilliam!) true charpath
0.5 setlinewidth
0.4 setgray
stroke
showpage
</graphic>
<description official="yes"
author="John">The All-England summarize Proust
competition <related terms="Marcel Proust"/>
</description>
</episode>
</show>
Conditional Sections
In order to easily include or ignore certain parts of a DTD, you can use conditional sections.
A conditional section has the following form:
<![includeDirective[
... all desired markup declarations ...
]]>
includeDirective is either INCLUDE or IGNORE. The markup declarations inside the section are
considered a part of the DTD or are plainly ignored, accordingly.
Entities
The last major features of DTDs (and XML as a language) are entity declaration and references.
Before studying their syntax, let’s review the concept of entities.
All XML documents are physically made up of entities: individual pieces of content, identified by
a name.
Entities are classified into four groups: internal general, external parsed general, unparsed, and
parameter. The following sections analyze the declaration and usage of each group.
The Only Anonymous Entity
The starting point for the parser is known as the document entity (normally the main file that holds
the XML declaration, the document type declaration, and the root element). The document entity
is the only entity that is not identified by a name.
Internal General (Parsed)
Internal general entities are the simplest parsed entities. They contain replacement text that
becomes part of the document. You define them inside entity declarations by specifying their name
and explicitly providing their replacement text.
The following declaration shows an example:
<!ENTITY isbn "0-14-004259-8">
An internal entity (as it is normally called) can only be referenced inside the document, not the
DTD. To reference it, you simply include its name inside the characters & and ; as follows:
&isbn; <!-- the effect of this is simply to include the replacement
text -->
External General (Parsed)
External general entities (external general for short) are a powerful mechanism of modularization.
They specify, using a public or system identifier, the name of an external resource that holds the
entity’s replacement text:
<!ENTITY chapter1 SYSTEM "C++XMLBook-Chapter1-Author.xml">
External general entities are included in the document using the same notation as their internal
counterpart:
&chapter1; <!-- this can only appear in the document, not in the DTD -->
Unparsed
Unparsed entities are the least-common entities. They are pieces of content that might not be text,
and if they are, they might not be XML. You declare them by specifying their name, their location
(using a public or system identifier), and their notation (their type).
The following example shows the declaration syntax (note the keyword NDATA and the notation
name):
<!NOTATION tiff PUBLIC
"-//Aldus Corporation//NOTATION Tagged Image File Format//EN" >
<!ENTITY aras-tiff SYSTEM "/usr/local/images/sa.tiff" NDATA tiff>
Unparsed entities are referenced by name in the value of entity-type attributes.
Parameter
Parameter entities are a powerful reuse mechanism for DTDs. They basically work like general
entities, but they can be used only inside the DTD. They are commonly used to encapsulate
reusable parts of the DTD and to improve its readability and maintainability, as shown here:
<!-- note the % character, which indicates the nature of this entity -->
<!ENTITY % number "CDATA">
<!ENTITY % months "jan|feb|mar|apr|may|jun|jul|
aug|sep|oct|nov|dec">
Parameter entities can be used only inside the document. They are referenced by placing their
name between % and ;:
<!ELEMENT date (#PCDATA)>
<!ATTLIST date
day %number; #IMPLIED
month (%months;) #IMPLIED
year %number; #REQUIRED>
Standalone
Near the beginning of this chapter, I mentioned the possibility of adding a standalone string to the
XML declaration:
<?xml version="1.0" standalone="yes"?>
Now that you know about entities, I am ready to give a precise definition of its semantics.
In a standalone document declaration, the value "yes" indicates that there are no markup
declarations external to the document entity (in the DTD external subset) that affect the
information passed from the XML processor to the application.
For example, if the external subset contains an attribute with a default value, the document cannot
be marked as standalone, because the attribute declaration would affect the information passed by
forcing the existence of a value, even when it was not specified in the document.
Character References
A character reference is an explicit inclusion of a Unicode character. (See Chapter 8 for a
discussion of Unicode and encodings.) This is especially helpful for including characters that are
not available on the keyboard, and to escape special characters such as <.
A character reference starts with either &#x or &# and ends with ;. The numeric code in between
is either the hexadecimal or decimal representation of the character code, respectively. The
following code shows an example:
Ф . А . А
<!-- This would display: ?.À.À. -->
Internal and External DTD Subsets
I’ll finalize our discussion of DTDs by presenting a final feature: internal versus external DTD
subsets.
A document may specify some local markup declarations without having to change the original
DTD. This is performed by enclosing them in square brackets at the end of the doctype
declaration:
<?xml version="1.0"?>
<!DOCTYPE show SYSTEM "shows_1_3.dtd"
[
<!ENTITY lastModified "$Id: show_1_3.dtd,v 1.3 02/02/02 6:10 Exp $">
剩余274页未读,继续阅读
u_root
- 粉丝: 4403
- 资源: 46
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
- AirKiss技术详解:无线传递信息与智能家居连接
- Hibernate主键生成策略详解
- 操作系统实验:位示图法管理磁盘空闲空间
- JSON详解:数据交换的主流格式
- Win7安装Ubuntu双系统详细指南
- FPGA内部结构与工作原理探索
- 信用评分模型解析:WOE、IV与ROC
- 使用LVS+Keepalived构建高可用负载均衡集群
- 微信小程序驱动餐饮与服装业创新转型:便捷管理与低成本优势
- 机器学习入门指南:从基础到进阶
- 解决Win7 IIS配置错误500.22与0x80070032
- SQL-DFS:优化HDFS小文件存储的解决方案
- Hadoop、Hbase、Spark环境部署与主机配置详解
- Kisso:加密会话Cookie实现的单点登录SSO
- OpenCV读取与拼接多幅图像教程
- QT实战:轻松生成与解析JSON数据
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功