资源描述
XML编程与应用教程第二版上机答案 上机题 1、 lt;?xml version=quot;1.0quot; encoding=quot;gb2312quot;?gt; lt;bookgt; lt;titlegt;XML 指南lt;/titlegt; lt;chaptergt;XML 入门简介 lt;paragt;什么是 HTMLlt;/paragt; lt;paragt;什么是 XMLlt;/paragt; lt;/chaptergt; lt;chaptergt;XML 语法 lt;paragt;XML 元素必须有结束标签lt;/paragt; lt;paragt;XML 元素必须正确的嵌套lt;/paragt; lt;/chaptergt; lt;/bookgt; 2、 lt;?xml version=quot;1.0quot; encoding=quot;gb2312quot;?gt; lt;employeesgt; lt;employeegt; lt;idgt;1lt;/idgt; lt;namegt;张三lt;/namegt; lt;agegt;32lt;/agegt; lt;sexgt;男lt;/sexgt; lt;addressgt;上海lt;/addressgt; lt;/employeegt; lt;employeegt; lt;idgt;2lt;/idgt; lt;namegt;李四lt;/namegt; lt;agegt;22lt;/agegt; lt;sexgt;男lt;/sexgt; lt;addressgt;北京lt;/addressgt; lt;/employeegt; lt;/employeesgt; 3、 lt;?xml version=quot;1.0quot; encoding=quot;gb2312quot;?gt; lt;studentsgt; lt;studentgt; lt;numbergt;1lt;/numbergt; lt;namegt;tomlt;/namegt; lt;scoregt;100lt;/scoregt; lt;/studentgt; lt;studentgt; lt;numbergt;2lt;/numbergt; lt;namegt;marylt;/namegt; lt;scoregt;98lt;/scoregt; lt;/studentgt; lt;/studentsgt; 第三章 上机题 1、 lt;?xml version=quot;1.0quot; encoding=quot;GB2312quot;?gt; lt;!ELEMENT 学生名册(学生+)gt; lt;!ELEMENT 学生(姓名,性别, 年龄)gt; lt;!ELEMENT 姓名(#PCDATA)gt; lt;!ELEMENT 性别(#PCDATA)gt; lt;!ELEMENT 年龄(#PCDATA)gt; lt;!ATTLIST 学生 学号 ID #REQUIREDgt; 2、 lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt; lt;NEWSPAPERgt; lt;ARTICLE AUTHOR='amp;NEWSPAPER;' EDITOR='amp;PUBLISHER;' DATE='2021-6-1' EDITION ='amp;COPYRIGHT;'gt; lt;HEADLINEgt;Environment Protectionlt;/ HEADLINEgt; lt;BYLINEgt; Material waste lt;/BYLINEgt; lt;LEADgt;amp;PUBLISHER;lt;/LEADgt; lt;BODYgt; it means the waste of substance or things from which something else can be made. For example, people throw away the used metal products and buy a new one, so the old metal waste accumulates. At last, they become waste. For example, when people finish reading newspaper, the paper will become waste. When the glass is broken, it also becomes waste. Nobody wants to use a broken window or drink with a broken glass or wear a pair of broken glasses. Once it is broken, it becomes waste. The rate of using plastics is increasing day by day. People use plastic bags because they are convenient. When they get home, they throw the plastics way, paying no attention to the environment. The more convenience plastics brings to us, the more plastic waste is produced. This is called "white pollution' as most plastics are white. Some of our products we use every day are made of rubber, just like the tyres and the bottom part of our shoes. Its true that rubber plays an important role in our life. However, it also brings us some trouble when it has been used for a long time and becomes old. The old tyres become waste because it cant break down by nature. This is really a big problem. lt;/BODYgt; lt;NOTESgt; Protecting the environment is not one persons duty; it depends on all of us. What can we do? Maybe a dozen. In a word, use what can reuse as much as possible. Remember, environment protection is not ones duty! lt;/NOTESgt; lt;/ ARTICLEgt; lt;/ NEWSPAPERgt; 3、 lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt; lt;!DOCTYPE NEWSPAPER lt;!ELEMENT NEWSPAPER (ARTICLE+)gt; lt;!ELEMENT ARTICLE (HEADLINE,BYLINE,LEAD,BODY,NOTES)gt; lt;!ELEMENT HEADLINE (#PCDATA)gt; lt;!ELEMENT BYLINE (#PCDATA)gt; lt;!ELEMENT LEAD (#PCDATA)gt; lt;!ELEMENT BODY (#PCDATA)gt; lt;!ELEMENT NOTES (#PCDATA)gt; lt;!ATTLIST ARTICLE AUTHOR CDATA #REQUIREDgt; lt;!ATTLIST ARTICLE EDITOR CDATA #IMPLIEDgt; lt;!ATTLIST ARTICLE DATE CDATA #IMPLIEDgt; lt;!ATTLIST ARTICLE EDITION CDATA #IMPLIEDgt; lt;!ENTITY NEWSPAPER quot;Vervet Logic Timesquot;gt; lt;!ENTITY PUBLISHER quot;Vervet Logic Pressquot;gt; lt;!ENTITY COPYRIGHT quot;Copyright 1998 Vervet Logic Pressquot;gt; gt; lt;NEWSPAPERgt; lt;ARTICLE AUTHOR='amp;NEWSPAPER;' EDITOR='amp;PUBLISHER;' DATE='2021-6-1' EDITION ='amp;COPYRIGHT;'gt; lt;HEADLINEgt;Environment Protectionlt;/ HEADLINEgt; lt;BYLINEgt; Material waste lt;/BYLINEgt; lt;LEADgt;amp;PUBLISHER;lt;/LEADgt; lt;BODYgt; it means the waste of substance or things from which something else can be made. For example, people throw away the used metal products and buy a new one, so the old metal waste accumulates. At last, they become waste. For example, when people finish reading newspaper, the paper will become waste. When the glass is broken, it also becomes waste. Nobody wants to use a broken window or drink with a broken glass or wear a pair of broken glasses. Once it is broken, it becomes waste. The rate of using plastics is increasing day by day. People use plastic bags because they are convenient. When they get home, they throw the plastics way, paying no attention to the environment. The more convenience plastics brings to us, the more plastic waste is produced. This is called "white pollution' as most plastics are white. Some of our products we use every day are made of rubber, just like the tyres and the bottom part of our shoes. Its true that rubber plays an important role in our life. However, it also brings us some trouble when it has been used for a long time and becomes old. The old tyres become waste because it cant break down by nature. This is really a big problem. lt;/BODYgt; lt;NOTESgt; Protecting the environment is not one persons duty; it depends on all of us. What can we do? Maybe a dozen. In a word, use what can reuse as much as possible. Remember, environment protection is not ones duty! lt;/NOTESgt; lt;/ ARTICLEgt; lt;/ NEWSPAPERgt; 第四章 上机题 1、 lt;?xml version=quot;1.0quot; encoding=quot;UTF-8quot;?gt; lt;xs:schema xmlns:xs=quot;lgt; lt;headgt; lt;titlegt;订单信息lt;/titlegt; lt;/headgt; lt;bodygt; lt;h2 align=quot;centerquot;gt;订单lt;/h2gt; lt;table border=quot;1quot; cellpadding=quot;0quot; align=quot;centerquot;gt; lt;trgt;lt;thgt;名称lt;/thgt;lt;thgt;数量lt;/thgt;lt;thgt;城市lt;/thgt;lt;thgt;邮编lt;/thgt;lt;/trgt; lt;xsl:for-each select=quot;/ Orders / Orderquot;gt; lt;trgt; lt;tdgt;lt;xsl:value-of select=quot;namequot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; number quot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; city quot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; zip quot;/gt;lt;/tdgt; lt;/trgt; lt;/xsl:for-eachgt; lt;/tablegt; lt;/bodygt; lt;/htmlgt; lt;/xsl:templategt; lt;/xsl:stylesheetgt; 2)、 lt;?xml version=quot;1.0quot; encoding=quot;gb2312quot; ?gt; lt;xsl:stylesheet version=quot;1.0quot; xmlns:xsl=quot;lgt; lt;headgt; lt;titlegt;订单信息lt;/titlegt; lt;/headgt; lt;bodygt; lt;h2 align=quot;centerquot;gt;订单lt;/h2gt; lt;table border=quot;1quot; cellpadding=quot;0quot; align=quot;centerquot;gt; lt;trgt;lt;thgt;名称lt;/thgt;lt;thgt;数量lt;/thgt;lt;thgt;城市lt;/thgt;lt;thgt;邮编lt;/thgt;lt;/trgt; lt;xsl:if test=quot;/OrderorderID=" A002"quot;gt; lt;trgt; lt;tdgt;lt;xsl:value-of select=quot;namequot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; number quot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; city quot;/gt;lt;/tdgt; lt;tdgt;lt;xsl:value-of select=quot; zip quot;/gt;lt;/tdgt; lt;/trgt; lt;/xsl:ifgt; lt;/tablegt; lt;/bodygt; lt;/htmlgt; lt;/xsl:templategt; lt;/xsl:stylesheetgt; 3)、 lt;?xml version=quot;1.0quot; encoding=quot;gb2312quot; ?gt; lt;xsl:stylesheet version=quot;1.0quot; xmlns:xsl=quot;lgt; lt;headgt; lt;titlegt;订单信息lt;/titlegt; lt;/headgt; lt;bodygt; lt;h2 align=quot;centerquot;gt;订单lt;/h2gt; lt;table border=quot;1quot; cellpadding=quot;0quot; align=quot;centerquot;gt; lt;trgt;lt;thgt;名称lt;/thgt;lt;thgt;数量lt;/thgt;lt;thgt;城市lt;/thgt;lt;thgt;邮编lt;/thgt;lt;/trgt; lt;xsl:if test=quot; city .="北京"quot;gt; lt;trgt; lt;tdgt;lt;xsl:v.
展开阅读全文