小弟搞的一棵XML+XSL的树!
------------------------------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>