XML高手请指点

dreamdlm 2007-09-14 11:15:08
一共5个XSL文件,一个DTD,一个XML,请给出具体实例实现以下功能

1。DTD定义全局
2。XML里有四部分数据,都可形成数据表格
3。5个XSL文件中有一个是完整页4个片断页,每个片断页中foreach一次XML中的数据,最后由完整页的XSL合成调用

<table border="1" bordercolor="#999999" cellpadding="3" cellspacing="0" style="border-collapse:collapse; width:700px;">
<tr style="font-weight:bold;">
<td style="height:30px;">Name</td>
<td>Superman The Flight</td>
<td>Scream Machile</td>
<td>Roller Coaster</td>
<td>Runaway Train</td>
<td>Rolling Thunder</td>
<td>Batman The Ride</td>
</tr>
<xsl:for-each select="Model_3/Data">
<tr>
<td align="left"><xsl:value-of select="Name"/></td>
<td><xsl:value-of select="Superman"/></td>
<td><xsl:value-of select="Scream"/></td>
<td><xsl:value-of select="Roller"/></td>
<td><xsl:value-of select="Runaway"/></td>
<td><xsl:value-of select="Rolling"/></td>
<td><xsl:value-of select="Batman"/></td>
</tr>
</xsl:for-each>

</table>
<table>
<tr>
<td><xsl:import href="map.xsl"/></td></tr>
</table>
...全文
226 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
dreamdlm 2007-09-27
  • 打赏
  • 举报
回复
谢谢何俊斌,其实这个问题在当天就解决了,不过还是把分给你

我的解决思路是

A,B,C,D,E 五个XSL文件

第一步,D -> Import E
第二步,C -> Import D
第三步,B -> Import C
第四步,A -> Import B

这样A就包含了其它多个文件,而且不需要写任何多余的代码!因为学金融的本来就会做网页嘛,所以这只是道智力测验
hejunbin 2007-09-20
  • 打赏
  • 举报
回复
所有文件放在同一个目录下,包括你的图片O.o
hejunbin 2007-09-20
  • 打赏
  • 举报
回复
adventureland.xml文件如下:

<?xml version="1.0" encoding="utf-8"?>
<?xml-stylesheet type="text/xsl" href="merge.xsl"?>
<adventureland>
<adventureland_info>
<title>Welcome to Adventure Land</title>
<content>Adventure Land is Australia’s largest and favorite theme park, located in the sunshine state of Queensland, and draws more visitors each year than any other theme park in the country. Adventure Land is home to nine areas, or “theme lands” along with other unique attractions for people of all ages. It has been well known as a safe, clean environment for families to enjoy quality time together. Adventure Land is an iconic leisure and entertainment destination second to none.
For ticket information, feedback and other enquiries, please contact us on 1 800 063 064 or write to Adventure Land at Adventure Land, Coomera Parkway, Queensland 4209.</content>
</adventureland_info>
<map>
<title>Adventure Land Map</title>
<content>Adventure land is an amusement park, contains various attractions ranging from motion simulators to jet coaster which is 79 meters tall and slow river rides. Old Country will bring you to the good old days and you could find yourself as a king or queen in the Golden kingdom. Lake Front is the best place to enjoy your breakfast combine with sunshine and great river view and Fantasy Forest is where you could find some fantasy animals and hold them in your arm. There are also a number of actual active film studios within the Movie Town.
In addition, costumed character performers also patrol the park, allowing visitors the chance to take photos with them. Minor street shows including skits and singing performances are also present. The All-Star Parade commences at 2.30 PM every day.</content>
<photo>Park_Map.jpg</photo>
</map>
<rides>
<title>Rides Information</title>
<content>Adventure land is a whole world of entertainment. From heart-thumping thrill rides like Scream Machine in Frontier Adventure to the colorful but gentle rides in Batman The Ride in Lake Front. Adventure land has something for everyone. Come on guys, try something.</content>
</rides>
<tickets>
<title>Pricing Guide</title>
<content>The one admission price for your Adventure Land theme park tickets covers all rides, shows and attractions. We strongly recommend that all children under the age of 14 years be accompanied by an adult who shall be solely responsible for their care and conduct whilst on these premises.

We also offer family Deals and student discounts, especially, students of the University of Queensland got the highest discount. Isn’t it a great deal?

All the ticket prices are list following:</content>
</tickets>
</adventureland>

1. Adventure Land info (adventureland_info.xsl)
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="adventureland.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="adventureland_info">
<xsl:value-of select="content" disable-output-escaping="yes"></xsl:value-of>
<hr />
</xsl:template>
</xsl:stylesheet>

2. Adventure Land park map (map.xsl)
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="adventureland.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="map">
<xsl:value-of select="content" disable-output-escaping="yes"></xsl:value-of>
<img src="{photo}" />
<hr />
</xsl:template>
</xsl:stylesheet>

3. Rides Information (rides.xsl)
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="adventureland.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="rides">
<xsl:value-of select="content" disable-output-escaping="yes"></xsl:value-of>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr />
</xsl:template>
</xsl:stylesheet>

4. Pricing Guide (tickets.xsl)
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="adventureland.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="utf-8"/>
<xsl:template match="tickets">
<xsl:value-of select="content" disable-output-escaping="yes"></xsl:value-of>
<table width="100%" border="1" cellspacing="0" cellpadding="0">
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
</table>
<hr />
</xsl:template>
</xsl:stylesheet>

5.merge.xsl
<?xml version="1.0" encoding="utf-8"?><!-- DWXMLSource="adventureland.xml" --><!DOCTYPE xsl:stylesheet [
<!ENTITY nbsp " ">
<!ENTITY copy "©">
<!ENTITY reg "®">
<!ENTITY trade "™">
<!ENTITY mdash "—">
<!ENTITY ldquo "“">
<!ENTITY rdquo "”">
<!ENTITY pound "£">
<!ENTITY yen "¥">
<!ENTITY euro "€">
]>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:import href="adventureland_info.xsl"></xsl:import>
<xsl:import href="map.xsl"></xsl:import>
<xsl:import href="rides.xsl"></xsl:import>
<xsl:import href="tickets.xsl"></xsl:import>
<xsl:output method="html" encoding="utf-8" doctype-public="-//W3C//DTD XHTML 1.0 Transitional//EN" doctype-system="http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"/>
<xsl:template match="/">

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title>Untitled Document</title>
<style type="text/css">
body {
font-size:12px/1.5; font-family:Verdana, Arial, Helvetica, sans-serif
}
</style>
</head>

<body>
<xsl:apply-imports ></xsl:apply-imports>
</body>
</html>

</xsl:template>
</xsl:stylesheet>
dreamdlm 2007-09-18
  • 打赏
  • 举报
回复
另外,请切记,不是XSLT里面混用JS,动脑才能算出来,我也是受朋友之托作这道题!
但试了很多种办法,求了很多XML高手都没用!
dreamdlm 2007-09-18
  • 打赏
  • 举报
回复
网页设计要求:
用XML来做一个主题公园的网页
网页要包括4个部分:
1. Welcome to Adventure Land
2. Adventure Land Park Map
3. Rides Information
4. Pricing Guide
每个部分要明确地分开(例如用一条横线),以及标题。
第一部分1. Welcome to Adventure Land。
把以下这段话写在网页中即可。

Welcome to Adventure Land
Adventure Land is Australia’s largest and favorite theme park, located in the sunshine state of Queensland, and draws more visitors each year than any other theme park in the country. Adventure Land is home to nine areas, or “theme lands” along with other unique attractions for people of all ages. It has been well known as a safe, clean environment for families to enjoy quality time together. Adventure Land is an iconic leisure and entertainment destination second to none.
For ticket information, feedback and other enquiries, please contact us on 1 800 063 064 or write to Adventure Land at Adventure Land, Coomera Parkway, Queensland 4209.

第2部分:Adventure Land Map
1.把以下这段话写在网页中:
Adventure land is an amusement park, contains various attractions ranging from motion simulators to jet coaster which is 79 meters tall and slow river rides. Old Country will bring you to the good old days and you could find yourself as a king or queen in the Golden kingdom. Lake Front is the best place to enjoy your breakfast combine with sunshine and great river view and Fantasy Forest is where you could find some fantasy animals and hold them in your arm. There are also a number of actual active film studios within the Movie Town.
In addition, costumed character performers also patrol the park, allowing visitors the chance to take photos with them. Minor street shows including skits and singing performances are also present. The All-Star Parade commences at 2.30 PM every day.
2然后把 这张地图贴在下面


第3部分 Rides Information
把下面这段话写在网页中:
Adventure land is a whole world of entertainment. From heart-thumping thrill rides like Scream Machine in Frontier Adventure to the colorful but gentle rides in Batman The Ride in Lake Front. Adventure land has something for everyone. Come on guys, try something.
然后做出下面这个表格:




第4部分:Pricing Guide

把下面这段话写在网页中:

The one admission price for your Adventure Land theme park tickets covers all rides, shows and attractions. We strongly recommend that all children under the age of 14 years be accompanied by an adult who shall be solely responsible for their care and conduct whilst on these premises.

We also offer family Deals and student discounts, especially, students of the University of Queensland got the highest discount. Isn’t it a great deal?

All the ticket prices are list following:

然后插入这张表格



注意表格最后一栏的眼神要跟上面这张一致。这个表格是用代码写出来的,不是直接把图贴上去的。

最后的XML必须成形有效,建议用XML编辑器来查看上述要求是否达到。网页必须能够在IE中浏览。构造4个XSL文件,文件名分别是

1. Adventure Land info (adventureland_info.xsl)
2. Adventure Land park map (map.xsl)
3. Rides Information (rides.xsl)
4. Pricing Guide (tickets.xsl)


另外必须用Merge file (merge.xsl)
文件来把所有的文件联系起来,展示在一个页面中。为了使文件更有可读性,必须包括一些解释XML代码含义。HTML可以使用来提高网页的效果,设计风格颜色自定。
文件做成压缩形式,里面包括

1. XML file name: adventureland.xml
2. DTD file name: adventureland.dtd
3. XSL file 1 (Adventure Land info) name: adventureland_info.xsl
4. XSL file 2 (Adventure Land Park map) name: map.xsl
5. XSL file 3 (Rides Information) name: rides.xsl
6. XSL file 4 (Tickets) name: tickets.xsl
7. XSL file 5 (在文件里) name: merge.xsl

8. Figure of the map for section II name: Park_Map.jpg
dreamdlm 2007-09-18
  • 打赏
  • 举报
回复
呀,两颗星就厉害了?基础?你做个看看?你做出这个题有300块钱,要想拿钱你就做啊,可以联系我,13910803701
cds27 2007-09-18
  • 打赏
  • 举报
回复
都是些XSLT的基础。来这抄作业答案的行为,不可取。
洋溢2016 2007-09-15
  • 打赏
  • 举报
回复
nan le
hejunbin 2007-09-15
  • 打赏
  • 举报
回复
给你个我写的例子:

http://www.hua2r.com/blog/3d52f4807c1ff7c2721da29c97660403.html
hejunbin 2007-09-15
  • 打赏
  • 举报
回复
?!O.o
你把原文地址我看看吧。。。
dreamdlm 2007-09-15
  • 打赏
  • 举报
回复
何俊斌的方法无效,只能实现简单效果,这个是国外经济学专业的一道题,不是纯技术性的问题

8,906

社区成员

发帖
与我相关
我的任务
社区描述
XML/XSL相关问题讨论专区
社区管理员
  • XML/XSL社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧