选择显示字体大小

用xslt轻松实现树形折叠导航栏(2)

  我引用花园的toc,一是让大家能有个初步印象,等文章完成后, 把几个文件c&p加上几个图片, 在ie5以上的机器上象打开一个html文件一样打开navi.xml后,就会出现跟花园很类似的toc了;二是希望大家根据它的层次结构来分析我的xml文件, 因为除顶层外, 我的层次安排和花园是一样的。 我来解释一下:layer相同表示元素处在同一层次即兄弟关系, childs的值表示该元素是否有子结点, 父子之间用ancestorid和id联系, 依次类推可以扩充至无限次深。 在xsl文件中根据layer的值用padding-left属性来实现树形,根据layer的值用display:none或block来实现折叠。 原理即此, 好,来看看这个关键的navigator.xsl: <?xml version="1.0" encoding="gb2312" ?>
<html>
<head>
<title>xslt树形导航栏</title>
<link rel="stylesheet" type="text/css" href="navigator.css"/>
<script src="toggle.js"></script>
</head>
<body>

<div xmlns:xsl="http://www.w3.org/tr/wd-xsl" >
<table>
<tr>
<td><div nowrap="true" style="padding-left:0em;">有座花园分类目录</div></td>
</tr>
<xsl:for-each select="navigation/navigator">
<tr>
<xsl:attribute name="title"><xsl:value-of select="@title" /></xsl:attribute>
<xsl:attribute name="class">navigator<xsl:if test="@layer[.>0]">-hidden</xsl:if></xsl:attribute>
<xsl:attribute name="id"><xsl:value-of select="@id"/></xsl:attribute>
<xsl:attribute name="ancestorid"><xsl:value-of select="@ancestorid"/></xsl:attribute>
<xsl:attribute name="depth"><xsl:value-of select="@layer"/></xsl:attribute>
<xsl:if test="@childs[.>0]">
<xsl:attribute name="expanded">no</xsl:attribute>
</xsl:if>
<td style="cursor:hand">
<div nowrap="true"><xsl:attribute name="style">padding-left:<xsl:value-of select="@layer"/>em;</xsl:attribute>
<xsl:choose>
<xsl:when test="@childs[.>0]"><img src="images/bs.gif"></img></xsl:when>
<xsl:otherwise><img><xsl:attribute name="src"><xsl:value-of select="@image" /></xsl:attribute></img></xsl:otherwise>
</xsl:choose>
<a><xsl:if test="@childs[.>0]"><xsl:attribute name="onclick">toggle('<xsl:value-of select="@id" />')</xsl:attribute></xsl:if><xsl:attribute name="href"><xsl:value-of select="@url" /></xsl:attribute><xsl:value-of select="@title" /></a></div></td>
</tr>
</xsl:for-each>
</table>
</div>
</body>
</html>


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons