请问在xsl里面用变量,但在ie中显示却显示varible不可用,有什么办法解决吗

whiteclude 2001-07-09 10:56:44
demotree.xml
<?xml version="1.0" encoding="gb2312" ?>
<?xml-stylesheet type="text/xsl" href="treefunc.xsl"?>
<project>
<pname>demotree</pname>
<node>
<layer>0</layer>
<id>1</id>
<name>node1</name>
<value>节点1</value>
<father>0</father>
<href></href>
</node>
<node>
<layer>0</layer>
<id>6</id>
<name>node3</name>
<value>节点3</value>
<father>0</father>
<href>http://www.163.net</href>
</node>
<node>
<layer>1</layer>
<id>3</id>
<name>node1_1</name>
<value>节点1_1</value>
<father>1</father>
<href></href>
</node>
<node>
<layer>1</layer>
<id>5</id>
<name>node1_2</name>
<value>节点1_2</value>
<father>1</father>
<href>www.5460.net</href>
</node>
<node>
<layer>2</layer>
<id>4</id>
<name>node1_1_1</name>
<value>节点1_1_1</value>
<father>3</father>
<href>www.sina.com</href>
</node>
<node>
<layer>0</layer>
<id>2</id>
<name>node2</name>
<value>节点2</value>
<father>0</father>
<href>link4</href>
</node>
</project>

treefunc.xsl

<?xml version="1.0" encoding="gb2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<html>
<head>
<style>
#foldheader{cursor:hand ; font-weight:bold ;
list-style-image:url(fold.gif)}
#foldinglist{list-style-image:url(list.gif)}
a:link{COLOR: #051679;TEXT-DECORATION: none}
a:visited{COLOR: #D91656;TEXT-DECORATION: none}
a:hover{COLOR: #cc0000;TEXT-DECORATION: underline}
body{FONT-SIZE: 10pt;}
</style>
</head>
<title>
<xsl:value-of select="project/pname"/>
</title>

<script for="window" event="onload">

<xsl:comment><![CDATA[
img1=new Image();
img1.src="fold.gif";
img2=new Image();
img2.src="open.gif";

function change(){
if(!document.all)
return;
if (event.srcElement.id=="foldheader") {
var srcIndex = event.srcElement.sourceIndex;
var nested = document.all[srcIndex+1];
if (nested.style.display=="none") {
nested.style.display='';
event.srcElement.style.listStyleImage="url(open.gif)";
}
else {
nested.style.display="none";
event.srcElement.style.listStyleImage="url(fold.gif)";
}
}
}
document.onclick=change;


]]></xsl:comment>
</script>

<body>
<xsl:value-of select="project/pname"/>
<ul>
<xsl:apply-templates select="project/node"/>
</ul>
</body>
</html>
</xsl:template>

<xsl:template match="node">
<xsl:for-each select=".[number(layer) $eq$ 0 ]">
<xsl:if test=".[href $eq$ '']">
<xsl:variable name="temp_id" ><xsl:value-of select="id"/></xsl:variable><!--我希望保存当前的树节点的id值-->
<li id="foldheader"><xsl:value-of select="value"/></li>
<ul id="foldinglist" style="display:none" >
<xsl:for-each select="/project/node[number(father) $eq$ $temp_id]"><!--当只有循环搜索到的节点的father与变量temp_id相同,才是其子节点,才显示出来-->
<li><a>
<xsl:attribute name="HREF">
<xsl:value-of select="href"/>
</xsl:attribute>
<xsl:value-of select="value"/></a></li>
</xsl:for-each>
</ul>
</xsl:if>
<xsl:if test=".[href $ne$ '']">
<li><a>
<xsl:attribute name="HREF">
<xsl:value-of select="href"/>
</xsl:attribute>
<xsl:value-of select="value"/></a></li>
</xsl:if>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>


请各位高手帮忙调试一下,有更好的办法也请告诉我,我还有更多的分给愿意帮我的人的
...全文
131 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
rabbit 2001-09-14
  • 打赏
  • 举报
回复
请问是怎么实现的
whiteclude 2001-07-10
  • 打赏
  • 举报
回复
谢了,本来就不想装msxml3,我换了个笨办法实现了xml文件的树型显示。
whiteclude 2001-07-09
  • 打赏
  • 举报
回复
是必须安装msxml3吗,是否改用较新版的msie就可以了,我现在用的是msie5.5
whiteclude 2001-07-09
  • 打赏
  • 举报
回复
请问是不是还要把这句<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
改了呢?
whiteclude 2001-07-09
  • 打赏
  • 举报
回复
我希望显示的结果是一个树的样子,大概是这样的:
-节点1
-节点1_1
-节点1_1_1
-节点1_2
+节点3
+节点2
karma 2001-07-09
  • 打赏
  • 举报
回复
你用的是微软实现的早期XSL版本,不支持variable,句法也不尽相同,安装MSXML3,使用XSLT标准吧
hydnoahark 2001-07-09
  • 打赏
  • 举报
回复
安装msxml3.0或以上版本后
>><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
改为
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
whiteclude 2001-07-09
  • 打赏
  • 举报
回复
我也已经安装了msxml3,但是还是报一样的错,不能使用variable
karma 2001-07-09
  • 打赏
  • 举报
回复
IE5.5 only supports MSXML2.6

8,906

社区成员

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

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