一个XPath的简单问题,急!!

oneway 2002-12-17 01:44:28
我随意查看csdn上的一篇帖子的原代码,然后它的内容保存下来,想自己写一个xsl去解析它,IE显示如下错误信息:

无法显示 XML 页。
使用 XSL 样式表无法查看 XML 输入。请更正错误然后单击 刷新按钮,或以后重试。


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

结束标记 'td' 与开始标记 'xsl:value-of' 不匹配。处理资源 'file:///C:/Documents and Settings/oneway/桌面/ddv/topic.xsl' 时出错。第 17 行,位置: 37

<td><xsl:value-of select="rank"></td>
------------------------------------^

我的xsl代码如下:
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/Transform" xmlns="http://www.w3.org/TR/REC-html40">

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

<xsl:template match="/">
<HTML>
<xsl:apply-templates select="/topic/issue/"/>
</HTML>
</xsl:template>

<xsl:template match="/topic/issue">
<TABLE BORDER="1">
<TR>
<td><xsl:value-of select="rank"></td>
</TR>
</TABLE>
</xsl:template>

</xsl:stylesheet>
...全文
131 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
oneway 2002-12-17
  • 打赏
  • 举报
回复
有什么不同?
ssm1226 2002-12-17
  • 打赏
  • 举报
回复
test:

<?xml version="1.0" encoding="gb2312"?>
<?xml-stylesheet type="text/xsl" href="11.xsl" ?>
<root>
<中>
<zhong>test</zhong>
</中>
</root>

11.xsl:

<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:fo="http://www.w3.org/1999/XSL/Format">
<xsl:template match="/">
<xsl:for-each select="/root/中">
<xsl:value-of select="zhong"/>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>

oneway 2002-12-17
  • 打赏
  • 举报
回复
哦~诸如"/topic/issue/"之类的地方?
saucer,我还想问一下,我的一个xml文件,他的节点有用中文命名的,
如“/计算机硬件设备登记表/基本情况/basic”,我在写xlt时也碰到了这样的问题,那该怎样解决?在声明的地方有“gb23123”呀,还是要把节点名都改回英文的?如果这样,xml声称是支持自定义标记的呀。
谢谢!
saucer 2002-12-17
  • 打赏
  • 举报
回复
XSLT是很严格的,命名空间的大小写必须一致,元素的大小写也必须一致,你对照一下你的编码与我上面的编码就知道了
oneway 2002-12-17
  • 打赏
  • 举报
回复
saucer,I got it!
could you please tell me why did so?
saucer 2002-12-17
  • 打赏
  • 举报
回复
XSLT is case-sensitive, try

<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns="http://www.w3.org/TR/REC-html40">
<xsl:template match="/">
<HTML>
<body>
<xsl:apply-templates select="/Topic/Issue"/>
</body>
</HTML>
</xsl:template>

<xsl:template match="Issue">
<TABLE BORDER="1">
<TR>
<td><xsl:value-of select="rank"/></td>
</TR>
</TABLE>
</xsl:template>

</xsl:stylesheet>
oneway 2002-12-17
  • 打赏
  • 举报
回复
ssm1226(雨中人) 我改成了一样的代码,还是没有,只有一个空格子。
ssm1226 2002-12-17
  • 打赏
  • 举报
回复
<?xml version="1.0" encoding="gb2312"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/xsl/Transform" xmlns="http://www.w3.org/TR/REC-html40">
<xsl:template match="/">
<HTML>
<xsl:apply-templates select="/topic/issue/"/>
</HTML>
</xsl:template>

<xsl:template match="/topic/issue">
<TABLE BORDER="1">
<TR>
<td><xsl:value-of select="rank"/></td>
</TR>
</TABLE>
</xsl:template>

</xsl:stylesheet>

oneway 2002-12-17
  • 打赏
  • 举报
回复
faint! 没有错误提示了,但是只有一个空格子?
ssm1226 2002-12-17
  • 打赏
  • 举报
回复
标记要关闭

同意楼上的
saucer 2002-12-17
  • 打赏
  • 举报
回复
try
<xsl:value-of select="rank"/>

8,906

社区成员

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

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