以文本方式查看主题

-  中文XML论坛 - 专业的XML技术讨论区  (http://bbs.xml.org.cn/index.asp)
--  『 XML基础 』  (http://bbs.xml.org.cn/list.asp?boardid=1)
----  [求助]Required attribute 'match' is missing,疑惑中......  (http://bbs.xml.org.cn/dispbbs.asp?boardid=1&rootid=&id=60370)


--  作者:whittiy07
--  发布时间:3/24/2008 7:44:00 PM

--  [求助]Required attribute 'match' is missing,疑惑中......
错误为:The XML page cannot be displayed
Cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later.
--------------------------------------------------------------------------------
Required attribute 'match' is missing.

文件为film.xml:
<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="film.xsl" ?>

<root>
<china>
<film>
<name>刮痧</name>
<director>郑晓龙</director>
<review>一部反映东西文化冲突、而又相互融合的影片</review>
<stars>梁家辉</stars>
<stars>蒋雯丽</stars>
</film>
<film>
<name>幸福时光</name>
<director>张艺谋</director>
<review>张艺谋的最新作品</review>
<stars>赵本山</stars>
<stars>董洁</stars>
</film>
</china>
<foreign>
<film>
<name>勇敢的心</name>
<director>梅尔.吉布森</director>
<review>苏格兰的民族英雄威廉.华莱士的故事</review>
<stars>梅尔.吉布森</stars>
<stars>索菲.玛索</stars>
</film>
<film>
<name>辛德勒的名单</name>
<director>斯皮尔伯格</director>
<review>二次世界大战期间,企业家辛德勒救助集中营中的犯人的故事</review>
<stars>利亚姆.尼森</stars>
<stars>本.金斯</stars>
</film>
</foreign>
</root>

----------------------------------------------------------------------------------------------------------------

film.xsl:

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" version="1.0" encoding="UTF-8" indent="yes" />

<xsl:template>
<xsl:apply-templates />
</xsl:template>

<xsl:template match="china">
<span style="font-size:14pt; color:red; font-weight:bolder;
display:block; text-align:center;">中国影片</span>
<table width="80%" align="center" border="1">
<xsl:for-each select="film">
<tr>
  <td colspan="1" width="20%">片名</td>
  <td colspan="3"><xsl:apply-templates select="name" /></td>
</tr>
<tr>
  <td>导演</td>
  <td width="20%"><xsl:apply-templates select="director" /></td>
  <td width="10%">主演</td>
  <td><xsl:apply-templates select="stars" /></td>
</tr>
<tr>
  <td>内容简介</td>
  <td colspan="3"><xsl:apply-templates select="review" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>

<xsl:template match="foreign">
<span style="font-size:14pt; color:red; font-weight:bolder;
display:block; text-align:center;">外国影片</span>
<table width="80%" align="center" border="1">
<xsl:for-each select="film">
<tr>
  <td colspan="1" width="20%">片名</td>
  <td colspan="3"><xsl:apply-templates select="name" /></td>
</tr>
<tr>
  <td>导演</td>
  <td width="20%"><xsl:apply-templates select="director" /></td>
  <td width="10%">主演</td>
  <td><xsl:apply-templates select="stars" /></td>
</tr>
<tr>
  <td>内容简介</td>
  <td colspan="3"><xsl:apply-templates select="review" /></td>
</tr>
</xsl:for-each>
</table>
</xsl:template>

<!-- 定义最底层的模板 -->
<xsl:template match="name">
<xsl:value-of />
</xsl:template>
<xsl:template match="director">
<xsl:value-of />
</xsl:template>
<xsl:template match="stars">
<xsl:value-of />
</xsl:template>
<xsl:template match="review">
<xsl:value-of />
</xsl:template>

</xsl:stylesheet>


这是怎么回事?刚学xml,求教高手解答。



--  作者:whittiy07
--  发布时间:3/25/2008 12:43:00 PM

--  
问题所在:
<xsl:template match="china">路径不对,修改为match="root/china"
同理,foreign类似,终于找到了,看来初学xml的时候找到一本好的教材实在是太重要了。
W 3 C h i n a ( since 2003 ) 旗 下 站 点
苏ICP备05006046号《全国人大常委会关于维护互联网安全的决定》《计算机信息网络国际联网安全保护管理办法》
7,908.203ms