为什么我的XML文件不能正确显示?

liugeasb 2004-11-23 05:17:23
第一个是XML文件:
<?xml version="1.0" encoding="GB2312"?>
<?xml-stylesheet type="text/xsl" href="Ex7-3.xsl" ?>
<!-- 2003年世界杯中国队所以C组情况 -->
<CnGame>
<Opponent>
<!-- ID="C1"表示该球队在C组的编号 -->
<TeamName ID="C1">巴西</TeamName>
<Place>韩国西归埔</Place>
<Date>2002年6月</Date>
<Time>19:30</Time>
<star>
<!-- Number="" 表明该球星的编号,下同 -->
<StarName Number=" ">罗纳而多</StarName>
<StarName Number=" ">里瓦尔多</StarName>
</star>
<Coach>
<CoachName>斯科拉里</CoachName>
<Birthday>1984年9月11日</Birthday>
<Interesting>上网</Interesting>
</Coach>
</Opponent>
<Opponent>
<!-- ID=C1 表明该球队在C组的编号 -->
<TeamName ID="C2">土耳其</TeamName>
<Place>韩国汉城</Place>
<Date>2002年6月12日</Date>
<Time>14:30</Time>
<Star>
<StarName>哈坎。苏克</StarName>
<StraName>奥坎</StraName>
</Star>
<Coach>
<CoachName>吉内斯</CoachName>
<Birthday>1995年</Birthday>
<Interesting>登山</Interesting>
</Coach>
</Opponent>
<Opponent>
<TeamName ID="C4">哥斯达黎加斯</TeamName>
<Place>韩国光广州</Place>
<Date>2002年12月12日</Date>
<Time>14:30</Time>
<Star>
<StarName>万乔普</StarName>
<StarName>梅森</StarName>
</Star>
<Coach>
<CaochName>吉马瑞</CaochName>
<Birthday>1959年12月20日</Birthday>
<Interesting>音乐</Interesting>
</Coach>
</Opponent>
</CnGame>

第二个是:
<?xml version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/xsl/Transform">
<xsl:template match="/">
<xsl:apply-templates></xsl:apply-templates>
</xsl:template>
<xsl:template match="/CnGame/Opponent">
<!-- 给CoachName加上编号 -->
<pre>
教练编号及名字
<xsl:value-of select="position()"/>
<xsl:value-of select="Coach/CoachName"/>
</pre>
</xsl:template>
</xsl:stylesheet>

用浏览器预览时,只看到“教练编号及名字”几个字,其它的全是空白,请各位指点这是怎么回事,谢谢了!
...全文
180 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
dotnetbus 2004-11-23
  • 打赏
  • 举报
回复
由于 xsl 的namespace不对,所以xsl compiler不能解析
<xsl:value-of>节
Gavin 2004-11-23
  • 打赏
  • 举报
回复
try:

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" >
<xsl:output method="html" indent="yes" doctype-public="-//W3C//DTD HTML 4.0 Final//EN" encoding="GB2312"/>


注意http://www.w3.org/1999/xsl/Transform -> http://www.w3.org/1999/XSL/Transform

还有你的xml 最后一个"/CnGame/Opponent" CaochName -> CoachName
dotnetbus 2004-11-23
  • 打赏
  • 举报
回复
xmlns:xsl="http://www.w3.org/1999/xsl/Transform"
改为
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"

8,906

社区成员

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

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