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. Linux开篇

    1.为什么学习Linux? 2.学习Linux的资料

  2. jquery 之节点操作

    一.添加节点 [添加内部子节点方法]:内部节点就是儿子节点 append()    在被选元素内部的结尾插入内容 appendTo()  将指定内容插入到被选标签内部的结尾 prepend()   在 ...

  3. 关于serialVersionUID与序列化"

    java序列化trick and trap 厂内经常出现序列化对象版本不匹配问题,于是发本文说明一些序列化的注意点 调用MQ.memcached.rpc等等涉及到远程通讯的都会经过序列化,虽然客户端透 ...

  4. sql join实例图解

    https://blog.codinghorror.com/a-visual-explanation-of-sql-joins/ 1. inner join: 所有满足join条件的两个table对应 ...

  5. 使用ifstream和getline读取文件内容[c++] ZZ

      假设有一个叫 data.txt 的文件, 它包含以下内容: Fry: One Jillion dollars.[Everyone gasps.]Auctioneer: Sir, that's no ...

  6. iTextSharp 使用详解(转) 感谢原著作者 .

    TextSharp是一个生成Pdf文件的开源项目,最近在项目中有使用到这个项目,对使用中的经验作一个小结. ITextSharp中相关的概念: 一.Document 这个对象有三个构造函数: 隐藏行号 ...

  7. Python学习---Django的新工程设置模板

    该模板完全可以在创建好新工程后进行部分代码替换 创建app01的  python startapp app01   创建static子目录 settings.py """ ...

  8. linux 三大利器 grep sed awk 正则表达式

    正则表达式目标 正则表达式单字符: 特定字符 范围字符:单个字符[ ] :代表查找单个字符,括号内为字符范围 数字字符:[0-9],[259] 查找 0~9 和 2.5 .9 中的任意一个字符 小写字 ...

  9. C#网络编程(一)基础篇

    简介: C#网络编程API包含在System.Net和System.Net.Sockets命名空间下,大部分网络操作都可以在其中找到相应的类来实现:包括Socket的创建和连接,网络流收发方法的封装, ...

  10. Python2.7 - IMOOC - 2

    第三章 Python变量和数据类型 3-1.数据类型 在Python中,能够直接处理的数据类型有以下几种: 整数 Python可以处理任意大小的整数,当然包括负整数,表示方法和数学上的写法一模一样,十 ...