In this tutorial you will create a well-formed and verified XML file. Consider the XML document below

<?xml version="1.0"?>
<!DOCTYPE ancient_wonders [
<!ELEMENT ancient_wonders (wonder*)>
<!ELEMENT wonder (name, location, height)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT location (#PCDATA)>
<!ELEMENT height (#PCDATA)>
<!ATTLIST height units CDATA #REQUIRED>
]>
<ancient_wonders>
<wonder>
<name>Colossus of Rhodes</name>
<location>Rhodes, Greece</location>
<height units="feet">107</height>
</wonder>
</ancient_wonders>

1. In the above XML document, add another ancient wonder element for the "Great Pyramid of Giza" located at Giza in Egypt and with the height of 455 feet. Save as “ancient-wonders.xml”

2. For element of Collossus of Rhodes in this XML document, just below the element, add an empty element <main_image> with attribute filename whose value is “colossus.jpg”.

3. Accomodate the DTD of “ancient-wonders.xml” to question 2.

4. Validate ancient-wonders.xml using xmllint.

5. Copy the “ancient_wonders” instance at the top (without DTD) to the XML instance document “ancient-wondersxsd.xml”.

6. Build an xml schema definition for ancient-wonders-xsd.xml and save it as “ancient-wonders.xsd”.

7. Validate the “ancient-wonders-xsd.xml” against “ancient-wonders.xsd” using xmllint. Submit the three documents via Stream.

第一,二,三问:

ancident-wonders.xml

<?xml version="1.0"?>
<!DOCTYPE ancient_wonders[
<!ELEMENT ancient_wonders (wonder*)>
<!ELEMENT wonder (name, main_image?, location, height)>
<!ELEMENT name (#PCDATA)>
<!ELEMENT main_image EMPTY>
<!ATTLIST main_image filename CDATA #REQUIRED>
<!ELEMENT location (#PCDATA)>
<!ELEMENT height (#PCDATA)>
<!ATTLIST height units CDATA #REQUIRED>
]> <ancient_wonders>
<wonder>
<name>Colossus of Rhodes</name>
<main_image filename="colossus.jpg"/>
<location>Rhodes, Greece</location>
<height units="feet">107</height>
</wonder> <wonder>
<name>Great Pyramid of Giza</name>
<location>Giza, Egypt</location>
<height units="feet">455</height>
</wonder>
</ancient_wonders>

第五问:

<ancient_wonders>
<wonder>
<name>Colossus of Rhodes</name>
<main_image filename="colossus.jpg"/>
<location>Rhodes, Greece</location>
<height units="feet">107</height>
</wonder>
<wonder>
<name>Great Pyramid of Giza</name>
<location>Giza, Egypt</location>
<height units="feet">455</height>
</wonder>
</ancient_wonders>

第六问:

<?xml version="1.0"?>
<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
<xs:element name="ancient_wonders">
<xs:complexType>
<xs:sequence minOccurs="0">
<xs:element name="wonder" type="wonder" maxOccurs="10"/>
</xs:sequence>
</xs:complexType>
</xs:element> <xs:complexType name="wonder">
<xs:sequence>
<xs:element name="name" type="xs:string"/>
<xs:element name="main_image" type="main_image" minOccurs="0"/>
<xs:element name="location" type="xs:string"/>
<xs:element name="height" type="height"/>
</xs:sequence>
</xs:complexType> <xs:complexType name="main_image">
<xs:attribute name="filename" type="xs:string" use="required"/>
</xs:complexType> <xs:complexType name="height">
<xs:simpleContent>
<xs:extension base="xs:integer">
<xs:attribute name="units" type="xs:string" use="required"/>
</xs:extension>
</xs:simpleContent>
</xs:complexType>
</xs:schema>

然后利用xmllint验证dtd,schema(非该题的检验 这里只给出相似的过程结果)

如果有错,则会指出相应错误

把答案写下来 下次复习的时候过来看_(:зゝ∠)_

XML第一次简单入门(Lab分析)的更多相关文章

  1. JAVA Bean和XML之间的相互转换 - XStream简单入门

    JAVA Bean和XML之间的相互转换 - XStream简单入门 背景介绍 XStream的简介 注解简介 应用实例 背景介绍 我们在工作中经常 遇到文件解析为数据或者数据转化为xml文件的情况, ...

  2. Asp.Net MVC学习总结(一)——Asp.Net MVC简单入门

    一.MVC简单入门 1.1.MVC概念 视图(View) 代表用户交互界面,对于Web应用来说,可以概括为HTML界面,但有可能为XHTML.XML和Applet. 模型(Model) 表示用户对其数 ...

  3. Python 简单入门指北(一)

    Python 简单入门指北(一) Python 是一门非常容易上手的语言,通过查阅资料和教程,也许一晚上就能写出一个简单的爬虫.但 Python 也是一门很难精通的语言,因为简洁的语法背后隐藏了许多黑 ...

  4. apache ftp server的简单入门(数据库验证)

    apache的简单校验分为两种,一直是前面提到的properties的校验,具体参考:apache ftp server的简单入门(properties验证) 今天来说一种数据库的校验,这种方式在项目 ...

  5. ArcGIS for Desktop入门教程_第四章_入门案例分析 - ArcGIS知乎-新一代ArcGIS问答社区

    原文:ArcGIS for Desktop入门教程_第四章_入门案例分析 - ArcGIS知乎-新一代ArcGIS问答社区 1 入门案例分析 在第一章里,我们已经对ArcGIS系列软件的体系结构有了一 ...

  6. 初学Python之爬虫的简单入门

    初学Python之爬虫的简单入门 一.什么是爬虫? 1.简单介绍爬虫   爬虫的全称为网络爬虫,简称爬虫,别名有网络机器人,网络蜘蛛等等. 网络爬虫是一种自动获取网页内容的程序,为搜索引擎提供了重要的 ...

  7. 用IntelliJ IDEA创建Gradle项目简单入门

    Gradle和Maven一样,是Java用得最多的构建工具之一,在Maven之前,解决jar包引用的问题真是令人抓狂,有了Maven后日子就好过起来了,而现在又有了Gradle,Maven有的功能它都 ...

  8. [原创]MYSQL的简单入门

    MYSQL简单入门: 查询库名称:show databases; information_schema mysql test 2:创建库 create database 库名 DEFAULT CHAR ...

  9. emacs最简单入门,只要10分钟

    macs最简单入门,只要10分钟  windwiny @2013    无聊的时候又看到鼓吹emacs的文章,以前也有几次想尝试,结果都是玩不到10分钟就退出删除了. 这次硬着头皮,打开几篇文章都看完 ...

随机推荐

  1. Volley框架实现Http的get和post请求

    一: volley简介: Google I/O 2013上,Volley发布了.Volley是Android平台上的网络通信库,能使网络通信更快,更简单,更健壮.这是Volley名称的由来: a bu ...

  2. 基于bootstrap模态框的alert弹窗

    完成的效果如下: html代码: <!-- 弹出框 --> <div class="modal fade" id="alert_like" t ...

  3. 五大常用算法之四:回溯法[zz]

    http://www.cnblogs.com/steven_oyj/archive/2010/05/22/1741376.html 1.概念 回溯算法实际上一个类似枚举的搜索尝试过程,主要是在搜索尝试 ...

  4. Linux 配置samba服务实现与Windows文件共享

    目录: 1.samba服务介绍 2. 安装samba服务和客户端 3.samba配置文件详解 4.配置实例 5.客户端挂载与测试 6.samba排错 1.Samba服务介绍     Samba 最先在 ...

  5. 搭建spring boot+elasticsearch+activemq服务

    目前时间是:2017-01-24 本文不涉及activemq的安装 需求 activemq实时传递数据至服务 elasticsearch做索引 对外开放查询接口 完成全文检索 环境 jdk:1.8 s ...

  6. December 16th 2016 Week 51st Friday

    My life is a straight line, turning only for you. 我的人生是一条直线,转弯只是为了你. My life is a straight line that ...

  7. 两天学会css基础(二)

    接上一篇博客,还有css中的两个重要知识点没有说到,就是元素的浮动与定位. 第三部分:元素的浮动与清除 这部分的内容之前的博客已总结过.请查看css中的浮动与三种清除浮动的方法这篇文章. 浮动在网页中 ...

  8. @property 装饰器

    property() 函数作用于新式类,返回属性值. class C(object): def __init__(self): self._x = None def getx(self): print ...

  9. 【[HNOI2008]GT考试】

    我又来复习\(kmp\)了 其实这道题主要是一个矩阵乘法,但是\(kmp\)在其中也有着非常重要的作用 我们可以这样定义状态\(dp[i][j]\)表示文本串进行到了\(i\)位置,同时文本串在最后和 ...

  10. 【[APIO2008]免费道路】

    \(kruskal\)好题 \(0\)边的数量在某些情况下是可以无限制的调控的,前提是所有必须存在的边都在生成树里了 所以应该分别求出有哪些边是必须在生成树里的,我们可以先从大到小排序,求出有哪些\( ...