欢迎光临
我们一直在努力

用Java实现可保存状态的数据库生成XML树,最后一个源码(12),新手高手都看看吧,也不枉我一片苦心啊!-JSP教程,Java与XML

建站超值云服务器,限时71元/月

6.3.3.xsl源码
1.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 ;list-style-image:url(/images/fold.gif);padding-left-width:-3}
#foldinglist{list-style-image:url(/images/list.gif);list-left-width:-3}
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>

<script for="window" event="onload">
<xsl:comment><![cdata][
    var temp_str = thexmltreecookie;
    var fl_n = 0;
    temp_str = temp_str + "=";
    for (i=0;i<foldinglist.length;i++){
            temp_str=temp_str+"0:";
        }
        temp_str = temp_str.substring(0,temp_str.length-1);
        fl_n = temp_str.length -17 ;
        if ((document.cookie == )||(wm_readcookie(thexmltreecookie).length != fl_n)){
            document.cookie = temp_str;
        }
        else {
            var temp_s = wm_readcookie("thexmltreecookie").split(":");
            for (i=0;i<foldinglist.length;i++){
                if (temp_s][i] == 0){
                           var tb =0;
                           for (j=0;tb < 1;j++){
                              if (document.all[j] == foldinglist[i]){
                                    tb = 1;
                                    document.all[j-1].style.liststyleimage="url(/images/fold.gif)";
                              }
                           }
                           foldinglist[i].style.display="none";
                    }
                    else {
                           var tb =0;
                           for (j=0;tb < 1;j++){
                              if (document.all[j] == foldinglist[i]){
                                    tb = 1;
                                    document.all[j-1].style.liststyleimage="url(/images/open.gif)";
                              }
                           }
                           foldinglist[i].style.display="";
                    }
             }
          }
]]></xsl:comment>
</script>

<script>

<xsl:comment><![cdata][
    img1=new image()
    img1.src="/images/fold.gif"
    img2=new image()
    img2.src="/images/open.gif"

    function change(){
              if(!document.all)
                 return;
              var temp_ss =wm_readcookie("thexmltreecookie").split(":");
              var temp_s = thexmltreecookie;
              temp_s = temp_s + =;
              if (event.srcelement.id=="foldheader") {
                 var srcindex = event.srcelement.sourceindex;
                 var nested = document.all][srcindex+1];
                 for (i=0;i<foldinglist.length;i++){
                        if (foldinglist[i] == nested){
                            var clickid;
                            clickid = "clickid="+event.srcelement.no;
                            document.cookie =clickid;
                            //alert(document.cookie);
                               if (temp_ss[i]==0){
                                  temp_ss[i]=1;
                               }
                               else {
                                 temp_ss[i]=0;
                               }
                        }
                 }
                 for (i=0;i<foldinglist.length;i++){
                        temp_s =temp_s+temp_ss[i]+:;
                 }
                 temp_s = temp_s.substring(0,temp_s.length-1);
                 document.cookie = temp_s;
                 //var clickid;
                 //clickid = "clickid="+nested;
                 //document.cookie = clickid;
                 //alert(document.cookie);
                 if (nested.style.display=="none") {
                        nested.style.display=
                        event.srcelement.style.liststyleimage="url(/images/open.gif)"
                 }
                 else {
                        nested.style.display="none"
                        event.srcelement.style.liststyleimage="url(/images/fold.gif)"
                 }
             top.topframe.location.reload();
              }
       }
       document.onclick=change;
       
       function wm_readcookie(name){
              //如果没有cookie则返回false或者取得值并返回该值
             if(document.cookie == ){
                   return false;
             }
             else {
                   return unescape(wm_getcookievalue(name));
             }  
       }
   
    function wm_getcookievalue(name){
              var firstchar,lastchar;
              var thebigcookie = document.cookie;
              firstchar = thebigcookie.indexof(name);
              if (firstchar != -1){
                 firstchar += name.length + 1;
                 // find the end of the value string (i.e. the next ;).
                 lastchar = thebigcookie.indexof(;, firstchar);
                 if(lastchar == -1) lastchar = thebigcookie.length;
                 // return the value.
                 return thebigcookie.substring(firstchar, lastchar);
              }
              else {
                 // if there was no cookie, return false.
                 return false;
              }
       }
]]></xsl:comment>
</script>

<body>
<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:element name ="li">
        <xsl:attribute name="id">foldheader</xsl:attribute>
        <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
        <xsl:value-of select="value"/>
       </xsl:element>
       <ul id="foldinglist" style="display:none" >
          <xsl:for-each select="./node[number(layer) $eq$ 1]">
           <xsl:if test=".[href $eq$ ]">
             <xsl:element name ="li">
              <xsl:attribute name="id">foldheader</xsl:attribute>
              <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
              <xsl:value-of select="value"/>
             </xsl:element>
             <ul id="foldinglist" style="display:none" >
              <xsl:for-each select="./node[number(layer) $eq$ 2]">
                <xsl:if test=".[href $ne$ ]">
                <li><xsl:element name ="a">
                <xsl:attribute name="href">
                <xsl:value-of select="href"/>
                </xsl:attribute>
                <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                <xsl:value-of select="value"/>
                </xsl:element></li>
                </xsl:if>
                <xsl:if test=".[href $eq$ ]">
                <xsl:element name ="li">
                 <xsl:attribute name="id">foldheader</xsl:attribute>
                 <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                 <xsl:value-of select="value"/>
                </xsl:element>
                <ul id="foldinglist" style="display:none" >
                <xsl:for-each select="./node[number(layer) $eq$ 3]">
                   <xsl:if test=".[href $ne$ ]">
                     <li><xsl:element name ="a">
                      <xsl:attribute name="href">
                      <xsl:value-of select="href"/>
                      </xsl:attribute>
                      <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                      <xsl:value-of select="value"/>
                      </xsl:element></li>
                   </xsl:if>
                   <xsl:if test=".[href $eq$ ]">
                     <xsl:element name ="li">
                      <xsl:attribute name="id">foldheader</xsl:attribute>
                      <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                      <xsl:value-of select="value"/>
                     </xsl:element>
                     <ul id="foldinglist" style="display:none" >
                     <xsl:for-each select="./node[number(layer) $eq$ 4]">
                        <xsl:if test=".[href $ne$ ]">
                        <li><xsl:element name ="a">
                        <xsl:attribute name="href">
                        <xsl:value-of select="href"/>
                        </xsl:attribute>
                        <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                        <xsl:value-of select="value"/>
                        </xsl:element></li>
                        </xsl:if>
                        <xsl:if test=".[href $eq$ ]">
                        <xsl:element name ="li">
                         <xsl:attribute name="id">foldheader</xsl:attribute>
                         <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                         <xsl:value-of select="value"/>
                        </xsl:element>
                        <ul id="foldinglist" style="display:none" >
                        <xsl:for-each select="./node[number(layer) $eq$ 5]">
                           <xsl:if test=".[href $ne$ ]">
                           <li><xsl:element name ="a">
                            <xsl:attribute name="href">
                            <xsl:value-of select="href"/>
                            </xsl:attribute>
                            <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                            <xsl:value-of select="value"/>
                           </xsl:element></li>
                           </xsl:if>
                           <xsl:if test=".[href $eq$ ]">
                           <xsl:element name ="li">
                            <xsl:attribute name="id">foldheader</xsl:attribute>
                            <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                            <xsl:value-of select="value"/>
                           </xsl:element>
                           <ul id="foldinglist" style="display:none" >
                           <xsl:for-each select="./node[number(layer) $eq$ 6]">
                              <xsl:if test=".[href $ne$ ]">
                              <li><xsl:element name ="a">
                               <xsl:attribute name="href">
                               <xsl:value-of select="href"/>
                               </xsl:attribute>
                               <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                               <xsl:value-of select="value"/>
                              </xsl:element></li>
                              </xsl:if>
                              <xsl:if test=".[href $eq$ ]">
                              <xsl:element name ="li">
                               <xsl:attribute name="id">foldheader</xsl:attribute>
                               <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                               <xsl:value-of select="value"/>
                              </xsl:element>
                              <ul id="foldinglist" style="display:none" >
                              <xsl:for-each select="./node[number(layer) $eq$ 7]">
                                 <xsl:if test=".[href $ne$ ]">
                                 <li><xsl:element name ="a">
                                  <xsl:attribute name="href">
                                  <xsl:value-of select="href"/>
                                  </xsl:attribute>
                                  <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                                  <xsl:value-of select="value"/>
                                 </xsl:element></li>
                                 </xsl:if>
                                 <xsl:if test=".[href $eq$ ]">
                                 <xsl:element name ="li">
                                  <xsl:attribute name="id">foldheader</xsl:attribute>
                                  <xsl:attribute name="no"><xsl:value-of select="id"/></xsl:attribute>
                                  <xsl:value-of select="value"/>
                                 </xsl:element>
                                 <ul id="foldinglist" style="display:none" >
                                 <xsl:for-each select="./node[number(layer) $eq$ 8]">
                                    <xsl:if test=".[href $ne$ ]">
                                    <li><xsl:element name ="a">
                                     <xsl:attribute name="href">
                                     <xsl:value-of select="href"/>
                                     </xsl:attribute>
                                     <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
                                     <xsl:value-of select="value"/>
                                    </xsl:element></li>
                                    </xsl:if>
                                 </xsl:for-each>
                                 </ul>
                                 </xsl:if>
                              </xsl:for-each>
                              </ul>
                              </xsl:if>
                           </xsl:for-each>
                           </ul>
                           </xsl:if>
                        </xsl:for-each>
                        </ul>
                        </xsl:if>
                     </xsl:for-each>
                     </ul>
                   </xsl:if>
                </xsl:for-each>
                </ul>
                </xsl:if>
              </xsl:for-each>
             </ul>
           </xsl:if>  
           <xsl:if test=".[href $ne$ ]">
            <li><xsl:element name ="a">
            <xsl:attribute name="href">
            <xsl:value-of select="href"/>
            </xsl:attribute>
            <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
            <xsl:value-of select="value"/>
            </xsl:element></li>
           </xsl:if>
          </xsl:for-each>
       </ul>
  </xsl:if>
  <xsl:if test=".[href $ne$ ]">
     <li><xsl:element name ="a">
            <xsl:attribute name="href">
            <xsl:value-of select="href"/>
            </xsl:attribute>
            <xsl:attribute name="target"><xsl:value-of select="target"/></xsl:attribute>
            <xsl:value-of select="value"/>
            </xsl:element>
     </li>
  </xsl:if>
  
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
  

赞(0)
版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com 特别注意:本站所有转载文章言论不代表本站观点! 本站所提供的图片等素材,版权归原作者所有,如需使用,请与原作者联系。未经允许不得转载:IDC资讯中心 » 用Java实现可保存状态的数据库生成XML树,最后一个源码(12),新手高手都看看吧,也不枉我一片苦心啊!-JSP教程,Java与XML
分享到: 更多 (0)

相关推荐

  • 暂无文章