如何用XML描述一个多级的树形菜单? 不如帖出来吧,把DTD和XML例子都帖一分出来。 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 thanks 9p(在问题中成长):[email protected] 谢谢。[email protected] 能发给我一份吗?谢谢。[email protected] Xtree.xml<?xml version='1.0'?><?xml-stylesheet type="text/xsl" href="xtree.xsl" ?><Level Name="Root" Opened="true" Loaded="true" Id="211"> <Level Name="Sub1" Loaded="true" Opened="false" Id="2131"> <Item URL="http://">Document0</Item> <Item URL="http://">Document01</Item> <Level URL="http://" Name="Sub11" Loaded="true" Opened="false" Id="2123"> <Level URL="http://" Name="Sub111" Loaded="true" Opened="false" Id="11"> <Item URL="http://">Document</Item> </Level> </Level> </Level> <Level Name="Sub2" Loaded="true" Opened="true" Id="44"> <Level Name="Sub21" URL="http://" Loaded="true" Opened="false" Id="3423"> <Item>Document2</Item> </Level> </Level></Level><?xml version='1.0'?><xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><!--//****************************************************************// You are free to copy the "XTree" scripts as long as you// keep this copyright notice://// original script concepts realized by// Author: Emmanuele De Andreis ([email protected]) Dec '2000// Located: http://www.duemetri.it/xtree//// *** SEE <WhatsNew.txt> FOR A LISTING OF MODIFICATIONS MADE ***//****************************************************************--> <xsl:template match="/"> <HTML> <HEAD> <link rel="stylesheet" href="xtree.css" /> <SCRIPT><![CDATA[ //Ora assegnamo la giusta chiamata alla funzione //per caricare il nodo o visualizzarlo function SetNode(nodeName) { if (eval("Node" + nodeName + ".Loaded == 'true';")) { if (eval("Items" + nodeName + ".style.display == 'none';")) { // Open eval("Image" + nodeName + ".src = 'images/minus.gif'"); eval("NodeImage" + nodeName + ".src = 'images/open.gif'"); eval("Items" + nodeName + ".style.display = 'block'"); } else { // Close eval("Image" + nodeName + ".src = 'images/plus.gif'"); eval("NodeImage" + nodeName + ".src = 'images/closed.gif'"); eval("Items" + nodeName + ".style.display = 'none'"); } } else { // Load alert('load'); } } ]]>//</SCRIPT> </HEAD> <BODY> <xsl:apply-templates/> </BODY> </HTML> </xsl:template> <xsl:template match="Level"> <DIV class="LevelHeader"> <xsl:attribute name="Id">Node<xsl:value-of select="@Id"/></xsl:attribute> <xsl:attribute name="Name"><xsl:value-of select="@Name"/></xsl:attribute> <xsl:attribute name="Loaded"><xsl:value-of select="@Loaded"/></xsl:attribute> <!-- Mettiamo il simbolo + o - Vediamo se il nodo e' aperto o chiuso --> <xsl:choose> <xsl:when test="@Opened[.='true']"> <IMG SRC="images/minus.gif"> <xsl:attribute name="Id">Image<xsl:value-of select="@Id"/></xsl:attribute> <xsl:attribute name="onClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute> </IMG> <IMG SRC="images/open.gif"> <xsl:attribute name="Id">NodeImage<xsl:value-of select="@Id"/></xsl:attribute> <xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute> </IMG> </xsl:when> <xsl:otherwise> <IMG SRC="images/plus.gif"> <xsl:attribute name="Id">Image<xsl:value-of select="@Id"/></xsl:attribute> <xsl:attribute name="onClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute> </IMG> <IMG SRC="images/closed.gif"> <xsl:attribute name="Id">NodeImage<xsl:value-of select="@Id"/></xsl:attribute> <xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute> </IMG> </xsl:otherwise> </xsl:choose> <xsl:choose> <xsl:when test="@URL"> <A><xsl:attribute name="HREF"><xsl:value-of select="@URL"/></xsl:attribute> <xsl:value-of select="@Name"/> </A> </xsl:when> <xsl:otherwise> <xsl:value-of select="@Name"/> </xsl:otherwise> </xsl:choose> </DIV> <DIV class="LevelItems"> <xsl:attribute name="Id">Items<xsl:value-of select="@Id"/></xsl:attribute> <xsl:choose> <xsl:when test="@Opened[.='true']"> <xsl:attribute name="Style">display: block; Margin-left: 16;</xsl:attribute> </xsl:when> <xsl:otherwise> <xsl:attribute name="Style">display: none; Margin-left: 16;</xsl:attribute> </xsl:otherwise> </xsl:choose> <xsl:apply-templates /> </DIV> </xsl:template> <xsl:template match="Item"> <DIV Class="Item"> <IMG SRC="images/blank.gif" /> <IMG SRC="images/document.gif" /> <xsl:choose> <xsl:when test="@URL"> <A><xsl:attribute name="HREF"><xsl:value-of select="@URL"/></xsl:attribute> <xsl:apply-templates /> </A> </xsl:when> <xsl:otherwise> <xsl:apply-templates /> </xsl:otherwise> </xsl:choose> </DIV> </xsl:template> <xsl:template match="text()"> <xsl:value-of /> </xsl:template></xsl:stylesheet> 还有个样式表.LevelHeader {font-size: 8pt}.LevelItems { font-size: 8pt; border-style: none}body {font-family: Tahoma} ths beloved() !!!!有例子大家就比较好办事了:)) 请教大家比较棘手的问题:接口开发 请教一个字节数组的问题!!!!! servlet的request的sendRedirect问题 java xml 中增加节点 急 !!!! Log4j配置问题 有关ResultSet取值问题,大家帮看看,谢谢 用AXIS自动生成客户端测试文件 工作流(OSWorkFlow)例子修改,使您快速上手 请教关于java流的问题 JASPERREPORT 套打 数据丢失 救命贴 谁能给我weblogic5.1的 weblogiclicense.java 和weblogiclicenses.xml文件? 推荐一本电子版的xml与java编程的书,告诉我下载地址。
[email protected]
[email protected]
[email protected]
<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="xtree.xsl" ?>
<Level Name="Root" Opened="true" Loaded="true" Id="211">
<Level Name="Sub1" Loaded="true" Opened="false" Id="2131">
<Item URL="http://">Document0</Item>
<Item URL="http://">Document01</Item>
<Level URL="http://" Name="Sub11" Loaded="true" Opened="false" Id="2123">
<Level URL="http://" Name="Sub111" Loaded="true" Opened="false" Id="11">
<Item URL="http://">Document</Item>
</Level>
</Level>
</Level>
<Level Name="Sub2" Loaded="true" Opened="true" Id="44">
<Level Name="Sub21" URL="http://" Loaded="true" Opened="false" Id="3423">
<Item>Document2</Item>
</Level>
</Level>
</Level>
<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"><!--
//****************************************************************
// You are free to copy the "XTree" scripts as long as you
// keep this copyright notice:
//
// original script concepts realized by
// Author: Emmanuele De Andreis ([email protected]) Dec '2000
// Located: http://www.duemetri.it/xtree
//
// *** SEE <WhatsNew.txt> FOR A LISTING OF MODIFICATIONS MADE ***
//****************************************************************
-->
<xsl:template match="/">
<HTML>
<HEAD>
<link rel="stylesheet" href="xtree.css" />
<SCRIPT><![CDATA[
//Ora assegnamo la giusta chiamata alla funzione
//per caricare il nodo o visualizzarlo
function SetNode(nodeName) {
if (eval("Node" + nodeName + ".Loaded == 'true';")) { if (eval("Items" + nodeName + ".style.display == 'none';")) {
// Open
eval("Image" + nodeName + ".src = 'images/minus.gif'");
eval("NodeImage" + nodeName + ".src = 'images/open.gif'");
eval("Items" + nodeName + ".style.display = 'block'");
}
else {
// Close
eval("Image" + nodeName + ".src = 'images/plus.gif'");
eval("NodeImage" + nodeName + ".src = 'images/closed.gif'");
eval("Items" + nodeName + ".style.display = 'none'");
}
}
else {
// Load
alert('load');
}
}
]]>//</SCRIPT>
</HEAD>
<BODY>
<xsl:apply-templates/>
</BODY>
</HTML>
</xsl:template>
<xsl:template match="Level">
<DIV class="LevelHeader">
<xsl:attribute name="Id">Node<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:attribute name="Name"><xsl:value-of select="@Name"/></xsl:attribute>
<xsl:attribute name="Loaded"><xsl:value-of select="@Loaded"/></xsl:attribute>
<!-- Mettiamo il simbolo + o -
Vediamo se il nodo e' aperto o chiuso -->
<xsl:choose>
<xsl:when test="@Opened[.='true']">
<IMG SRC="images/minus.gif">
<xsl:attribute name="Id">Image<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:attribute name="onClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute>
</IMG>
<IMG SRC="images/open.gif">
<xsl:attribute name="Id">NodeImage<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute>
</IMG>
</xsl:when>
<xsl:otherwise>
<IMG SRC="images/plus.gif">
<xsl:attribute name="Id">Image<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:attribute name="onClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute>
</IMG>
<IMG SRC="images/closed.gif">
<xsl:attribute name="Id">NodeImage<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:attribute name="onDblClick">SetNode('<xsl:value-of select="@Id"/>');</xsl:attribute>
</IMG>
</xsl:otherwise>
</xsl:choose> <xsl:choose>
<xsl:when test="@URL">
<A><xsl:attribute name="HREF"><xsl:value-of select="@URL"/></xsl:attribute>
<xsl:value-of select="@Name"/>
</A>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="@Name"/>
</xsl:otherwise>
</xsl:choose>
</DIV>
<DIV class="LevelItems">
<xsl:attribute name="Id">Items<xsl:value-of select="@Id"/></xsl:attribute>
<xsl:choose>
<xsl:when test="@Opened[.='true']">
<xsl:attribute name="Style">display: block; Margin-left: 16;</xsl:attribute>
</xsl:when>
<xsl:otherwise>
<xsl:attribute name="Style">display: none; Margin-left: 16;</xsl:attribute>
</xsl:otherwise>
</xsl:choose>
<xsl:apply-templates />
</DIV>
</xsl:template>
<xsl:template match="Item">
<DIV Class="Item">
<IMG SRC="images/blank.gif" />
<IMG SRC="images/document.gif" />
<xsl:choose>
<xsl:when test="@URL">
<A><xsl:attribute name="HREF"><xsl:value-of select="@URL"/></xsl:attribute>
<xsl:apply-templates />
</A>
</xsl:when>
<xsl:otherwise>
<xsl:apply-templates />
</xsl:otherwise>
</xsl:choose>
</DIV>
</xsl:template>
<xsl:template match="text()">
<xsl:value-of />
</xsl:template></xsl:stylesheet>
.LevelHeader {font-size: 8pt}
.LevelItems { font-size: 8pt; border-style: none}
body {font-family: Tahoma}