DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> XML學習教程 >> XML詳解 >> 我也貼一個,用的時候只要配制好xml文件就行了,連程序都不
我也貼一個,用的時候只要配制好xml文件就行了,連程序都不
編輯:XML詳解     
載XSLT模塊,程序下載地址:
演示地址:



51.Net上不支持xslt :(
程序文件:
===========================================================
<?PHP
$xslstring = implode(@#@#,file("navigator.xsl"));
$xmlstring = implode(@#@#,file("navi.XML"));
$arguments = array(
     @#/_xml@# => $XMLstring,
     @#/_xsl@# => $xslstring
);

$xh = xslt_create();

$result = xslt_process($xh, @#arg:/_XML@#, @#arg:/_xsl@#, NULL, $arguments);
if ($result) {
    print $result;
}
else {
    print "Err";
    
}
xslt_free($xh);

?>
XML文件
===========================================================
<?XML version="1.0" encoding="GB2312"?>
<?XML-stylesheet type="text/xsl" href="navigator.xsl" ?>
<Navigation>

    <Navigator ID="1" AncestorID="1" Layer="0" Title="花園首頁" Childs="0" Url="default.ASP&amp" Image="images/dc.gif"/>
    <Navigator ID="2" AncestorID="2" Layer="0" Title="我的花園" Childs="4" Url="#" Image="default"/>
    <Navigator ID="3" AncestorID="2" Layer="1" Title="收藏夾" Childs="4" Url="#" Image="default"/>
    <Navigator ID="21" AncestorID="3" Layer="2" Title="我管理的花壇" Childs="0" Url="mybbs.ASP?cat=g" Image="images/dc-new.gif"/>
    <Navigator ID="22" AncestorID="3" Layer="2" Title="我種下的種子" Childs="0" Url="mybbs.ASP?cat=t" Image="images/dc-new.gif"/>
    <Navigator ID="23" AncestorID="3" Layer="2" Title="我喜歡的花園" Childs="0" Url="myfavorite.ASP?cat=g&s=test" Image="images/dc-new.gif"/>
    <Navigator ID="24" AncestorID="3" Layer="2" Title="我收藏的文章" Childs="0" Url="myfavorite.ASP?cat=t" Image="images/dc-new.gif"/>
    <Navigator ID="4" AncestorID="2" Layer="1" Title="個人工具箱" Childs="2" Url="#" Image="default"/>
    <Navigator ID="25" AncestorID="4" Layer="2" Title="配置和管理" Childs="0" Url="personal.ASP" Image="images/dc-config.gif"/>
    <Navigator ID="26" AncestorID="4" Layer="2" Title="花瓣兌換點" Childs="0" Url="apetal.ASP" Image="images/dc-config.gif"/>
    <Navigator ID="27" AncestorID="2" Layer="1" Title="我的日記本" Childs="0" Url="mydiary.ASP" Image="images/dc-diary.gif"/>
    <Navigator ID="6" AncestorID="2" Layer="1" Title="好友和短訊" Childs="0" Url="myfrIEnd.ASP" Image="images/dc-frIEnds.gif"/>
    <Navigator ID="7" AncestorID="7" Layer="0" Title="計算機技術" Childs="2" Url="#" Image="default"/>
    <Navigator ID="8" AncestorID="7" Layer="1" Title="DHtml,JScript" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="9" AncestorID="7" Layer="1" Title=".Net,ASP+探討" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="10" AncestorID="7" Layer="1" Title="ASP互助" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="11" AncestorID="11" Layer="0" Title="箐箐校園" Childs="2" Url="#" Image="default"/>
    <Navigator ID="12" AncestorID="11" Layer="1" Title="南京大學" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="13" AncestorID="11" Layer="1" Title="東南大學" Childs="0" Url=&quo t;bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="14" AncestorID="14" Layer="0" Title="花園·有個廣場" Childs="2" Url="#" Image="default"/>
    <Navigator ID="15" AncestorID="14" Layer="1" Title="意見箱" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="16" AncestorID="14" Layer="1" Title="花園·人物故事" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="17" AncestorID="17" Layer="0" Title="園丁辦公室" Childs="0" Url="bbsgroup.ASP" Image="images/dc-key.gif"/>
    <Navigator ID="18" AncestorID="18" Layer="0" Title="青青芳草地" Childs="0" Url="bbsgroup.ASP" Image="images/dc.gif"/>
    <Navigator ID="19" AncestorID="19" Layer="0" Title="統計信息" Childs="0" Url="vIEwlog.ASP" Image="images/dc-chart.gif"/>
    <Navigator ID="20" AncestorID="20" Layer="0" Title="ActiveCard" Childs="0" Url="activecard?fromgarden" Image="images/dc-card.gif"/>
</Navigation>


XSLT文件

============================================================
<?XML version="1.0" encoding="GB2312"?>
<xsl:stylesheet version="1.0" XMLns:xsl="http://www.w3.org/1999/XSL/Transform">
    <xsl:output method ="Html" version="1.0" encoding="GB2312" indent="yes"/>
    <xsl:template match="/">
<Html>
    <HEAD>
        <TITLE>XSLT樹形導航欄</TITLE>
        <LINK rel="stylesheet" type="text/css" href="navigator.CSS"/>
        <SCRIPT src="toggle.JS"></SCRIPT>
    </HEAD>
    <BODY>
    
        <DIV >
            <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>
                       &nbsp;<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"><xsl:attribute name="onclick">toggle(@#<xsl:value-of select="@ID" />@#)</xsl:attribute></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>
</xsl:template>
</xsl:stylesheet>
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved