个人记录贴——XML实验报告

实验一 XML基础与XML编辑器的使用

一.实验目的

1、掌握XML1.0的标准及内容

2、掌握XML的基本格式

3、掌握XML SPY或VSCode的基本使用方法

二.实验内容

1、使用XML Spy或记事本等文本编辑器编辑如下XML文档,并保存文件名为code1_1.xml,然后在IE中浏览。

 

<?xml version="1.0" encoding="gb2312" ?>

<orders>

  <order>

    <customerID>c0500069</customerID>

    <order_date>20050517</order_date>

    <order_status>pending</order_status>

    <items>

      <item>

       <bookID>001</bookID>

       <quantity>10</quantity>

        <item_status>pending</item_status>

      </item>

    </items>

  </order>

  <order>

    <customerID>c500701</customerID>

    <order_date>20050712</order_date>

    <order_status>pending</order_status>

    <items>

      <item>

       <bookID>002</bookID>

       <quantity>30</quantity>

        <item_status>pending</item_status>

      </item>

      <item>

       <bookID>003</bookID>

       <quantity>20</quantity>

        <item_status>pending</item_status>

      </item>

    </items>

  </order>

</orders>

 

2、下面是一个网上购物订单,将它写成XML格式,并用XML SPY或VSCode编辑,保存为code1_2.xml。

顾客编号:X00349827,订单号:DD934809,订货时间:2004-05-17;

付款方式:邮局汇款,通讯地址:xxx市xxx路xxx号,邮编:123456;

汇款地址:yyy市yyy路yyy号,收款人xxxx书店;

定书号:001,书名:AAA,数量:1,价格:34.00;

定书号:002,书名:BBB,数量:1,价格:29.00;

定书号:003,书名:CCC,数量:1,价格:41.00。

 

实验二 XML DTD 与XML Schema的使用

一.实验目的

1、掌握DTD的定义、引用

2、掌握DTD的验证

3、掌握XML Schema的定义、引用

4、掌握XML Schema的验证

5、了解XML Schema中名称空间的使用

二.实验内容

1、如图所示,为其设计XML及其对应的DTD,分别命名为code2_1.xml、code2_1.dtd。

 

2、在一个XML文档中,需要用到一个article的结点,这个结点结构如下:

 

<article>

    <HeadLine section="business">

      <MainHead>Main headline goes here</MainHead>

      <SubHead>A subheadline goes here</SubHead>

    </HeadLine>

    <ByLine>

      <Author>John Doe</Author>

      <title>Reporter</title>

    </ByLine>

        <DateLine>April 30, 2005</Dateline>

       <body>Content of story goes here…</body>

        <stats>  

        <submitted>2005-03-02</submitted>

        <wordCount>1523</wordCount>

    </stats>

</article>

 

(1)请在分别定义HeadLine、ByLine、DateLine、stats结点的数据类型基础上,再定义article的复杂数据类型。

(2)若以上程序段多篇文章(articles),XML保存为code2_2.xml请为其建立完整的XML Schema文件,保存文件名为code2_2.xsd。

3、为 以下XML 文档设计对应的XML Schema文件,保存文件名为code2_3.xsd,XML文件保存为code2_3.xml

<?xml version="1.0" encoding="ISO-8859-1"?>

<shiporder orderid="889923"

xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

xsi:noNamespaceSchemaLocation="shiporder.xsd">

 <orderperson>George Bush</orderperson>

 <shipto>

  <name>John Adams</name>

  <address>Oxford Street</address>

  <city>London</city>

  <country>UK</country>

 </shipto>

 <item>

  <title>Empire Burlesque</title>

  <note>Special Edition</note>

  <quantity>1</quantity>

  <price>10.90</price>

 </item>

 <item>

  <title>Hide your heart</title>

  <quantity>1</quantity>

  <price>9.90</price>

 </item>

</shiporder>

实验三 CSS 与XSLT的应用

一.实验目的

1、掌握XML 和 CSS显示的方法

2、了解XSLT使用方法

3、体会两者的区别。

二.实验内容

1、按要求完成案例(如下图),其功能是实现后台管理的界面显示。

(1)编辑 XML文档,如code3_1.xml。

(2)编写对应的 XSLT 样式表,如code3_1.xsl。

(3)显示这个由 XSLT 样式表格式化的界面。

实验四 XML与Java

一.实验目的

1、掌握Java使用DOM加载XML的方法;

2、掌握使用DOM创建XML文件的方法;

3、学会转换XML文件为HTML的方法。

二.实验内容

1、示例6.1,使用Java语言解析XML文件,创建XML节点。

2、示例5.12。使用Java语言转换XML文件为HTML的方法。

猜你喜欢

转载自www.cnblogs.com/Kxia/p/10646080.html
今日推荐