XML编程与应用教程第二版上机答案.docx
《XML编程与应用教程第二版上机答案.docx》由会员分享,可在线阅读,更多相关《XML编程与应用教程第二版上机答案.docx(42页珍藏版)》请在冰豆网上搜索。
XML编程与应用教程第二版上机答案
上机题
1、
xmlversion="1.0"encoding="gb2312"?
>
XML指南XML入门简介
什么是HTML
什么是XML
XML语法
XML元素必须有结束标签
XML元素必须正确的嵌套
2、
xmlversion="1.0"encoding="gb2312"?
>
1
张三
32
男
上海
2
李四
22
男
北京3、
xmlversion="1.0"encoding="gb2312"?
>
1
tom
100
2
mary
98
第三章
上机题
1、
xmlversion="1.0"encoding="GB2312"?
>
ELEMENT学生名册(学生+)>
ELEMENT学生(姓名,性别,年龄)>
ELEMENT姓名(#PCDATA)>
ELEMENT性别(#PCDATA)>
ELEMENT年龄(#PCDATA)>
ATTLIST学生学号ID#REQUIRED>
2、
xmlversion="1.0"encoding="UTF-8"?
>
EnvironmentProtection
Materialwaste
&PUBLISHER;
itmeansthewasteofsubstanceorthingsfromwhichsomethingelsecanbemade.Forexample,peoplethrowawaytheusedmetalproductsandbuyanewone,sotheoldmetalwasteaccumulates.Atlast,theybecomewaste.Forexample,whenpeoplefinishreadingnewspaper,thepaperwillbecomewaste.Whentheglassisbroken,italsobecomeswaste.Nobodywantstouseabrokenwindowordrinkwithabrokenglassorwearapairofbrokenglasses.Onceitisbroken,itbecomeswaste.Therateofusingplasticsisincreasingdaybyday.Peopleuseplasticbagsbecausetheyareconvenient.Whentheygethome,theythrowtheplasticsway,payingnoattentiontotheenvironment.Themoreconvenienceplasticsbringstous,themoreplasticwasteisproduced.Thisiscalled“whitepollution”asmostplasticsarewhite.Someofourproductsweuseeverydayaremadeofrubber,justlikethetyresandthebottompartofourshoes.It’struethatrubberplaysanimportantroleinourlife.However,italsobringsussometroublewhenithasbeenusedforalongtimeandbecomesold.Theoldtyresbecomewastebecauseitcan’tbreakdownbynature.Thisisreallyabigproblem.
Protectingtheenvironmentisnotoneperson’sduty;itdependsonallofus.Whatcanwedo?
Maybeadozen..
Inaword,usewhatcanreuseasmuchaspossible.Remember,environmentprotectionisnotone’sduty!
3、
xmlversion="1.0"encoding="UTF-8"?
>
DOCTYPENEWSPAPER[
ELEMENTNEWSPAPER(ARTICLE+)>
ELEMENTARTICLE(HEADLINE,BYLINE,LEAD,BODY,NOTES)>
ELEMENTHEADLINE(#PCDATA)>
ELEMENTBYLINE(#PCDATA)>
ELEMENTLEAD(#PCDATA)>
ELEMENTBODY(#PCDATA)>
ELEMENTNOTES(#PCDATA)>
ATTLISTARTICLEAUTHORCDATA#REQUIRED>
ATTLISTARTICLEEDITORCDATA#IMPLIED>
ATTLISTARTICLEDATECDATA#IMPLIED>
ATTLISTARTICLEEDITIONCDATA#IMPLIED>
ENTITYNEWSPAPER"VervetLogicTimes">
ENTITYPUBLISHER"VervetLogicPress">
ENTITYCOPYRIGHT"Copyright1998VervetLogicPress">
]>
EnvironmentProtection
Materialwaste
&PUBLISHER;
itmeansthewasteofsubstanceorthingsfromwhichsomethingelsecanbemade.Forexample,peoplethrowawaytheusedmetalproductsandbuyanewone,sotheoldmetalwasteaccumulates.Atlast,theybecomewaste.Forexample,whenpeoplefinishreadingnewspaper,thepaperwillbecomewaste.Whentheglassisbroken,italsobecomeswaste.Nobodywantstouseabrokenwindowordrinkwithabrokenglassorwearapairofbrokenglasses.Onceitisbroken,itbecomeswaste.Therateofusingplasticsisincreasingdaybyday.Peopleuseplasticbagsbecausetheyareconvenient.Whentheygethome,theythrowtheplasticsway,payingnoattentiontotheenvironment.Themoreconvenienceplasticsbringstous,themoreplasticwasteisproduced.Thisiscalled“whitepollution”asmostplasticsarewhite.Someofourproductsweuseeverydayaremadeofrubber,justlikethetyresandthebottompartofourshoes.It’struethatrubberplaysanimportantroleinourlife.However,italsobringsussometroublewhenithasbeenusedforalongtimeandbecomesold.Theoldtyresbecomewastebecauseitcan’tbreakdownbynature.Thisisreallyabigproblem.
Protectingtheenvironmentisnotoneperson’sduty;itdependsonallofus.Whatcanwedo?
Maybeadozen..
Inaword,usewhatcanreuseasmuchaspossible.Remember,environmentprotectionisnotone’sduty!
第四章
上机题
1、
xmlversion="1.0"encoding="UTF-8"?
>
schemaxmlns:
xs="http:
//www.w3.org/2001/XMLSchema">
elementname="Orders"type="ord"/>
complexTypename="ord">
elementname="Order">
complexType>
sequence>
elementname="name"type="xs:
string"/>
elementname="number"type="numgs"/>
elementname="city"type="xs:
string"/>
elementname="zip"type="zipgs"/>
sequence>
attributename="orderID"type="idgs"use="required"/>
attributename="orderDate"type="xs:
date"use="optional"/>
complexType>
element>
complexType>
simpleTypename=“zipgs”>
restrictionbase=“xs:
string”>
lengthvalue=“6”/>
patternvalue=“\d{6}”/>
restriction>
simpleType>
simpleTypename=“idgs”>
restrictionbase=“xs:
string”>
lengthvalue=“4”/>
patternvalue=“[A]{1}\d{3}”/>
restriction>
simpleType>
simpleTypename=“numgs”>
restrictionbase=“xs:
positiveInteger”>
maxInclusivevalue=“99”/>
minInclusicevalue=“1”/>
restriction>
simpleType>
schema>
2、
xmlversion="1.0"?
>
schemaxmlns:
xsd="http:
//www.w3.org/2001/XMLSchema">
attributename="PRODID"type="pid"/>
simpleTypename="pid">
restrictionbase="xsd:
string">
patternvalue="[P]{1}\d{3}"/>
restriction>
simpleType>
elementname="PRODUCTDATA"type="prdata"/>
complexTypename="prdata">
sequence>
elementname="PRODUCT">
complexType>
sequence>
elementname="PRODUCTNAME"type="xsd:
string"/>
elementname="DESCRIPTION"type="xsd:
string"/>
elementname="PRICE"type="xsd:
positiveInteger"/>
elementname="QUANTITY"type="xsd:
nonNegativeInteger"/>
sequence>
attributeref="PRODID"use="required">
attribute>
attributename="CATEGORY"type="cat"use="required"/>
complexType>
element>
sequence>
complexType>
si9mpleTypename="cat">
restrictionbase="xsd:
string">
enumerationvalue="Toy"/>
enumerationvalue="Book"/>
restriction>
simpleType>
schema>
3、
xmlversion="1.0"encoding="UTF-8"?
>
schemaxmlns:
xs="http:
//www.w3.org/2001/XMLSchema">
elementname="PURCHASEORDER"type="pur"/>
complexTypename="pur">
elementname="Order">
complexType>
sequence>
elementname="DATE"type="xs:
date"/>
elementname="PRODUCTNAME"type="xs:
string"/>
elementname="SUPPLIERNAME"type="xs:
string"/>
elementname="ADDRESS"type="xs:
string"/>
elementname="QUANTITY"type="xs:
positiveInteger"/>
elementname="PRICEPERQTY"type="xs:
positiveInteger"/>
sequence>
complexType>
element>
attributename="ORDERID"type="xs:
string"use="required"/>
attributename="PRODID"type="xs:
string"use="optional"/>
complexType>
schema>
第五章
上机题
1、
1)、
xmlversion="1.0"encoding="gb2312"?
>
stylesheetversion="1.0"xmlns:
xsl="http:
//www.w3.org/1999/XSL/Transform">
templatematch="/">
订单信息
订单
名称 | 数量 | 城市 | 邮编 |
---|
for-eachselect="/Orders/Order">
value-ofselect="name"/> | value-ofselect="number"/> | value-ofselect="city"/> | value-ofselect="zip"/> | /tr>
for-each>
template>
stylesheet>
2)、
xmlversion="1.0"encoding="gb2312"?
>
stylesheetversion="1.0"xmlns:
xsl="http:
//www.w3.org/1999/XSL/Transform">
templatematch="/">
订单信息
订单
名称 | 数量 | 城市 | 邮编 |
---|
iftest="//Order[@orderID='A002']">
value-ofselect="name"/> | value-ofselect="number"/> | value-ofselect="city"/> | value-ofselect="zip"/> |
if>
template>
stylesheet>
3)、
xmlversion="1.0"encoding="gb2312"?
>
stylesheetversion="1.0"xmlns:
xsl="http:
//www.w3.org/1999/XSL/Transform">
templatematch="/">
订单信息
订单
名称 | 数量 | 城市 | 邮编 |
---|
iftest="city[.='北京']">
value-ofselect="name"/> | value-ofselect="number"/> | value-ofselect="city"/> | value-ofselect="zip"/> |
if>