小弟搞的一棵XML+XSL的树!

jinsanqi 2003-04-03 06:13:01
------------------------------TREE.XSL---------------------------------

<?xml version="1.0" encoding="GB2312" ?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl" version="1.0">
<xsl:template match="text()" >
<xsl:value-of/>
</xsl:template>
<!-- 处理每一个结点 http://www.w3.org/1999/XSL/Transform/1.0 -->
<xsl:template match="/">
<html>
<head>
<title>导航</title>
<meta http-equiv="Content-Type" content="text/html; charset=GB2312"/>
<META content="" name="KEYWORDS" />
<META content='' name='AUTHOR' />
<style type='text/css'>
A:link {TEXT-DECORATION: none;COLOR: #336699;}
A:visited {TEXT-DECORATION: none;COLOR: #336699;}
A:hover {TEXT-DECORATION: underline;COLOR: #666666;}
A:active {TEXT-DECORATION: none;COLOR: #336699;}
BODY,TD,TH {FONT-FAMILY: 宋体;FONT-SIZE: 9pt;COLOR: #000000;}
INPUT,SELECT {BACKGROUND-COLOR: ;COLOR: ;FONT-FAMILY: 宋体;FONT-SIZE: 9pt;}
LI {COLOR: #000000;}
.t01 {BORDER-TOP: #000000 1px solid;BORDER-BOTTOM: #000000 1px solid;BORDER-LEFT: #000000 1px solid;BORDER-RIGHT: #000000 1px solid;}
.t02 {BORDER-BOTTOM: #000000 1px solid;BORDER-LEFT: #000000 1px solid;BORDER-RIGHT: #000000 1px solid;}
.t03 {BORDER-RIGHT: #000000 1px solid;}
.t04 {BORDER-BOTTOM: #000000 1px solid;}
.t05 {BORDER-LEFT: #000000 1px solid;}
.t06 {BORDER-TOP: #000000 1px solid;BORDER-BOTTOM: #000000 1px solid;}
.i01 {BACKGROUND-COLOR: ;COLOR: ;}
.i02 {BACKGROUND-COLOR: ;COLOR: ;}
.BakLink:link {TEXT-DECORATION: none;COLOR: ;}
.BakLink:visited {TEXT-DECORATION: none;COLOR: ;}
.BakLink:hover {TEXT-DECORATION: underline;COLOR: ;}
.BakLink:active {TEXT-DECORATION: none;COLOR: ;}
.lm{font-family: Webdings;font-size: 16px;color: #9EBBDA;cursor: hand;}
.lmn {font-family: 宋体;font-size: 9pt;color: ;cursor: hand;}
.ToolBoxLink:link {TEXT-DECORATION: none;COLOR: ;}
.ToolBoxLink:visited {TEXT-DECORATION: none;COLOR: ;}
.ToolBoxLink:hover {TEXT-DECORATION: underline;COLOR: ;}
.ToolBoxLink:active {TEXT-DECORATION: none;COLOR: ;}
</style>

<SCRIPT LANGUAGE="javascript">
<xsl:comment><![CDATA[

function SwitchMenu (obj)
{
if (obj.style.display == 'none')
obj.style.display = '';
else
obj.style.display = 'none';
}
function turnit(ss,ii){
if (ss.style.display=="none"){
ss.style.display="";
ii.src="sub.gif"; //- 图片
}else{
ss.style.display="none";
ii.src="plus.gif"; //+ 图片
}
}
]]>//</xsl:comment>
</SCRIPT>

</head>
<body bgcolor='#F6F6F6' background='' leftMargin='5' topMargin='0' marginheight='0'>
<br/><br/>
<table>
<tr><td><xsl:value-of select="//Info/Title" /></td></tr>
<tr><td>欢迎你,<xsl:value-of select="//Info/UserName" /></td></tr>
</table>
<br/>
<table ><tr><td>
<xsl:for-each select="//Tree">
<xsl:apply-templates select="TreeNode"/>
</xsl:for-each>
</td></tr></table>
</body>
</html>
</xsl:template>

<!-- 如果是一个父栏目
-->
<!--处理开始-->
<xsl:template match="TreeNode">
<xsl:if test="@type[.='0']">
<xsl:if test="HaveChildren[.='true']" >
<table cellspacing="0" cellpadding="0">
<tr>
<xsl:element name="td">
<xsl:attribute name="onMouseDown">turnit(class<xsl:value-of select="ID"/>,pic<xsl:value-of select="ID"/>)</xsl:attribute>
<xsl:element name="img">
<xsl:attribute name="id">pic<xsl:value-of select="ID"/></xsl:attribute>
<xsl:attribute name="src">plus.gif</xsl:attribute>
</xsl:element>
<img src="inbox.gif" />
<xsl:element name="a">

<xsl:attribute name="href=#"/>
<xsl:attribute name="target"><xsl:value-of select="Target"/></xsl:attribute>
<xsl:value-of select="Name"/>
</xsl:element>
</xsl:element>
</tr>
<xsl:element name="tr">
<!--这里定义的id,style是干嘛的??-->
<xsl:attribute name="id">class<xsl:value-of select="ID"/></xsl:attribute>
<xsl:attribute name="style">display:none</xsl:attribute>
<td>
<table cellspacing="0" cellpadding="0" ><tr><td width="20" background="ver.gif" ></td>
<td>
<xsl:apply-templates select="TreeNode"/>
</td></tr></table>
</td>
</xsl:element>
</table>
</xsl:if>
</xsl:if>

<!-- 子结点 -->
<xsl:if test="@type[.='1']">
<table cellspacing="0" cellpadding="0">
<tr>
<td ><img src="cross.gif"/><img src="sent.gif"/>
<xsl:element name="a">
<!-- 奇怪,href后面怎么会加上文件所在系统路径???-->
<xsl:attribute name="href"><xsl:value-of select="URL"/>&id=<xsl:value-of select="ID"/>name=<xsl:value-of select="Name"/></xsl:attribute>
<xsl:attribute name="target"><xsl:value-of select="Target"/></xsl:attribute>
<xsl:value-of select="Name"/>
</xsl:element>
</td>
</tr></table>
</xsl:if>
</xsl:template>
<!--结束-->

</xsl:stylesheet>
...全文
117 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
jinsanqi 2003-04-04
  • 打赏
  • 举报
回复
有人吗?
jinsanqi 2003-04-03
  • 打赏
  • 举报
回复
有几个图片就没办法放上来了,把上面两个文件拷到同一目录下通过IE就可以运行了.多谢指教
jinsanqi 2003-04-03
  • 打赏
  • 举报
回复
有兴趣的朋友一起来探讨一下,有什么好改进的地方请大家多多建议,
emal:jinsanqin@163.com qq:38451400
---------------------------------TREE.XML--------------------------------
<?xml version="1.0" encoding="gb2312" ?>
<!--我把它放到我的jboss下面,链接TREE.XML文件,树显示不出来,TREE.XSL没能装上, 怎么回事,它们放在同一文件下的
-->
<?xml-stylesheet type='text/xsl' href='TREE.xsl'?>
<Navigate>
<Info>
<Title>树目录</Title>
<UserName>鸟人</UserName>
<Image>image</Image>
<ImageOpen>imageOpen</ImageOpen>
<ImageEntity>imageEntity</ImageEntity>
</Info>

<Tree>

<TreeNode type="0" >
<ID>1117</ID>
<Name>浙江</Name>
<TreeNode type="0" >
<ID>124</ID>
<Name>杭州</Name>
<TreeNode type="0" >
<ID>2117</ID>
<Name>文三路</Name>
<TreeNode type="1" >
<ID>2117</ID>
<Name>骆家庄</Name>
<URL>../entslt/a0301?act=toMan</URL>
</TreeNode>
<HaveChildren>true</HaveChildren>
</TreeNode>
<TreeNode type="1">
<ID>111</ID>
<Name>河南</Name>
<URL>http://www.zz.ha.cn</URL>
</TreeNode>
<HaveChildren>true</HaveChildren>
</TreeNode>

<TreeNode type="0" >
<ID>122</ID>
<Name>绍兴</Name>
<TreeNode type="1">
<ID></ID>
<Name>退出</Name>
<URL>../index.jsp</URL>
<Target>_top</Target>
</TreeNode>
<HaveChildren>false</HaveChildren>
</TreeNode>
<HaveChildren>true</HaveChildren>
</TreeNode>

<TreeNode type="1">
<ID></ID>
<Name>退出</Name>
<URL>../index.jsp</URL>
<Target>_top</Target>
</TreeNode>
</Tree>
</Navigate>

8,906

社区成员

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

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