2012-08-23 3 views
1

기존 메뉴 출력을 수정할 응용 프로그램을 작성 중입니다. 나는 이것을 할 수있는 여러 가지 방법을 가지고 있는데, 그 중 하나는 XSLT라고 생각하지만 나는 그러한 변형에서 완전한 초보자이다. 새로운으로XSLT 중첩 된 메뉴 변형 된 특성을 기반으로 변환

<ul> 
    <li><a href="#">Item1</a> 
    <ul> 
     <li class="featured"><a href="#">Item 1.1</a></li> 
     <li><a href="#">Item 1.2</a></li> 
     <li class="featured"><a href="">Item 1.3</a></li> 
     <li><a href="#">Item 1.4</a></li> 
    </ul> 
    </li> 
</ul> 

:

나는 다음과 같은 변경을 찾고

<ul> 
    <li><a href="#">Item1</a> 
    <ul> 
     <li> 
     <ul> 
      <li><a href="#">Item 1.1</a></li> 
      <li><a href="#">Item 1.2</a></li> 
      <li><a href="#">Item 1.3</a></li> 
      <li><a href="#">Item 1.4</a></li> 
     </ul> 
     </li> 
     <li> 
     <ul class="featured"> 
      <li><a href="#">Item 1.1</a></li> 
      <li><a href="#">Item 1.3</a></li> 
     </ul> 
     </li> 
    </ul> 
    </li> 
</ul> 

I가 다음과 같은 질문 :

나는 위의 무엇을 필요 변환?

n 레벨만으로 어떻게 제한합니까 (이 경우 ul.ul.ul.li 항목의 하위 항목, 즉 x.x 항목을 포함시키지 않겠습니까?).

상단이있는 스타일에만이 변환을 적용하고 "style2"으로 설정하면 다른 변환이 적용됩니까?

+0

이것은 인 XSLT에서의 빵과 버터. 내가 할 일은 [ID 변환] (http://en.wikipedia.org/wiki/Identity_transform#Using_XSLT)에서 시작한 다음 특정 템플릿을 추가하여 변경 사항을 하나씩 추가하는 것입니다. (전체 솔루션은이 사이트에서 너무 길어서 다소 일반적인 의견이라고 생각합니다.) – biziclop

답변

1

저는 ul의 추가 레벨을 추가하는 이유를 100 % 확신하지 못하고 "n- 레벨"깊은 요구 사항에 대해 확신하지 못합니다. (더 좋은 예는 도움이 될 것입니다.) 그러나 이것은 시작해야합니다 :

XSLT 1.0

<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> 
    <xsl:output indent="yes"/> 
    <xsl:strip-space elements="*"/> 

    <xsl:template match="@*|node()"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|node()"/> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="ul[@class='style1']/li"> 
     <xsl:copy> 
      <xsl:apply-templates select="@*|*[not(self::ul)]"/> 
      <ul> 
       <li> 
        <xsl:apply-templates select="ul"/> 
       </li> 
       <li> 
        <ul class="featured"> 
         <xsl:apply-templates select="ul/li[@class='featured']"/> 
        </ul> 
       </li> 
      </ul> 
     </xsl:copy> 
    </xsl:template> 

    <xsl:template match="li"> 
     <xsl:copy> 
      <xsl:apply-templates/> 
     </xsl:copy> 
    </xsl:template> 

</xsl:stylesheet> 

출력

<ul class="style1"> 
    <li> 
     <a href="#">Item1</a> 
     <ul> 
     <li> 
      <ul> 
       <li> 
        <a href="#">Item 1.1</a> 
       </li> 
       <li> 
        <a href="#">Item 1.2</a> 
       </li> 
       <li> 
        <a href="">Item 1.3</a> 
       </li> 
       <li> 
        <a href="#">Item 1.4</a> 
       </li> 
      </ul> 
     </li> 
     <li> 
      <ul class="featured"> 
       <li> 
        <a href="#">Item 1.1</a> 
       </li> 
       <li> 
        <a href="">Item 1.3</a> 
       </li> 
      </ul> 
     </li> 
     </ul> 
    </li> 
</ul> 
1

당신은 당신이 어떤 문제에 직면하는 경우 알려 주시기 바랍니다이 XSLT에게

<?xml version="1.0" encoding="UTF-8"?> 

<xsl:stylesheet 
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform" 
    xmlns:php="http://php.net/xsl" exclude-result-prefixes="php" version="1.0"> 
    <xsl:output method="html" version="1.0" encoding="utf-8" indent="yes" omit-xml-declaration="no"/> 

    <xsl:template match="/"> 
    <div id="menu"> 
     <ul id="mega"> 
     <xsl:for-each select="//Menu/MainMenu"> 
      <xsl:choose> 
      <xsl:when test="@isdisplay=1 and @iscategory=1"> 
       <xsl:element name="li"> 
       <xsl:attribute name="style"> 
        border-left:#ffffff 1px solid; 
       </xsl:attribute> 
       <xsl:attribute name="class"> 
        <xsl:value-of select="@class"/> 
       </xsl:attribute> 
       <xsl:variable name="name"> 
        <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
        <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php',$name,'','','')"/> 
        </xsl:attribute> 
        <xsl:value-of select="@displayname"/> 
       </xsl:element> 
       <xsl:if test="count(SubMenu) > 0"> 
        <xsl:choose> 
        <xsl:when test="@name='Outdoor Gear'"> 
         <div> 
         <xsl:apply-templates select="//Menu/MainMenu[@name='Outdoor Gear']"> 
         </xsl:apply-templates> 
         </div> 
        </xsl:when> 
        <xsl:when test="@name='Clothing/Footwear'"> 
         <div style="width:490px !important;"> 
         <xsl:apply-templates select="//Menu/MainMenu[@name='Clothing/Footwear']"></xsl:apply-templates> 
         </div> 
        </xsl:when> 
        <xsl:when test="@name='Electronics'"> 
         <div style="width:200px !important;"> 
         <xsl:apply-templates select="//Menu/MainMenu[@name='Electronics']"></xsl:apply-templates> 
         </div> 
        </xsl:when> 
        <xsl:when test="@name='Gifts'"> 
         <div style="width:200px !important;"> 
         <xsl:apply-templates select="//Menu/MainMenu[@name='Gifts']"></xsl:apply-templates> 
         </div> 
        </xsl:when> 
        <xsl:when test="@name='Petzl'"> 
         <div style="width:200px !important;"> 
         <xsl:apply-templates select="//Menu/MainMenu[@name='Petzl']"></xsl:apply-templates> 
         </div> 
        </xsl:when> 
        </xsl:choose> 
       </xsl:if> 
       </xsl:element> 
      </xsl:when> 
      <xsl:when test="@isdisplay=1 and @iscategory=0"> 
       <xsl:element name="li"> 
       <xsl:attribute name="style"> 
        border-left:#ffffff 1px solid; 
       </xsl:attribute> 
       <xsl:attribute name="class"> 
        <xsl:value-of select="@class"/> 
       </xsl:attribute> 
       <xsl:variable name="name"> 
        <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
        <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','',$name,'','','')"/> 
        </xsl:attribute> 
        <xsl:value-of select="@displayname"/> 
       </xsl:element> 
       </xsl:element> 
      </xsl:when> 
      </xsl:choose> 
     </xsl:for-each> 
     </ul> 
    </div> 
    </xsl:template> 

    <xsl:template match="//Menu/MainMenu[@name='Outdoor Gear']"> 
    <span class="main"> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Water Sport']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Water Sport']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Water Sport']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Water Sport']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 

     <br clear="all" /> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Archery']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Archery']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Archery']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Archery']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 

     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Climbing']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Climbing']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Climbing']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Climbing']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 

     <br clear="all" /> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Fishing']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Fishing']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Fishing']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Fishing']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 
    </span> 

    <span class="main"> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Track/Field/Court/Indoors']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Track/Field/Court/Indoors']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Track/Field/Court/Indoors']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Track/Field/Court/Indoors']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 

     <br clear="all" /> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Hiking and Camping']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Hiking and Camping']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Hiking and Camping']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="//Menu/MainMenu[@name='Outdoor Gear']/SubMenu[@name='Hiking and Camping']/@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Outdoor Gear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 
    </span> 
    </xsl:template> 

    <xsl:template match="//Menu/MainMenu[@name='Clothing/Footwear']"> 
    <span class="main"> 
     <h2> 
     <xsl:variable name="name"> 
      <xsl:value-of select="SubMenu[@name='Mountain Running']/@name"/> 
     </xsl:variable> 
     <xsl:element name="a"> 
      <xsl:attribute name="href"> 
      <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing/Footwear',$name,'','')"/> 
      </xsl:attribute> 
      <xsl:value-of select="SubMenu[@name='Mountain Running']/@displayname" disable-output-escaping="yes"/> 
     </xsl:element> 
     </h2> 
     <xsl:for-each select="SubMenu[@name='Mountain Running']/SubSubMenu"> 
     <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
      <xsl:variable name="name"> 
       <xsl:value-of select="../@name"/> 
      </xsl:variable> 
      <xsl:variable name="name1"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing/Footwear',$name,$name1,'')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </span> 
     </xsl:if> 
     <xsl:for-each select="ChildMenu"> 
      <xsl:if test="@isdisplay=1"> 
      <span class="inner"> 
       <xsl:variable name="name"> 
       <xsl:value-of select="../../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name1"> 
       <xsl:value-of select="../@name"/> 
       </xsl:variable> 
       <xsl:variable name="name2"> 
       <xsl:value-of select="@name"/> 
       </xsl:variable> 
       <xsl:element name="a"> 
       <xsl:attribute name="href"> 
        <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Clothing/Footwear',$name,$name1,$name2)"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
       </xsl:element> 
      </span> 
      </xsl:if> 
     </xsl:for-each> 
     </xsl:for-each> 
    </span> 
    </xsl:template> 

    <xsl:template match="//Menu/MainMenu[@name='Electronics']"> 
    <table width="100%" border="0" cellspacing="2" cellpadding="2"> 
     <tr> 
     <td height="5"></td> 
     </tr> 
     <xsl:for-each select="SubMenu"> 
     <tr> 
      <td class=""> 
      <xsl:variable name="name"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Electronics',$name,'','')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </xsl:template> 

    <xsl:template match="//Menu/MainMenu[@name='Gifts']"> 
    <table width="100%" border="0" cellspacing="2" cellpadding="2"> 
     <tr> 
     <td height="5"></td> 
     </tr> 
     <xsl:for-each select="SubMenu"> 
     <tr> 
      <td class=""> 
      <xsl:variable name="name"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Gifts',$name,'','')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </xsl:template> 

    <xsl:template match="//Menu/MainMenu[@name='Petzl']"> 
    <table width="100%" border="0" cellspacing="2" cellpadding="2"> 
     <tr> 
     <td height="5"></td> 
     </tr> 
     <xsl:for-each select="SubMenu"> 
     <tr> 
      <td class=""> 
      <xsl:variable name="name"> 
       <xsl:value-of select="@name"/> 
      </xsl:variable> 
      <xsl:element name="a"> 
       <xsl:attribute name="href"> 
       <xsl:value-of select="php:function('ClsXSLTFunction::makeFriendlyURL','Category.php','Petzl',$name,'','')"/> 
       </xsl:attribute> 
       <xsl:value-of select="@displayname" disable-output-escaping="yes"/> 
      </xsl:element> 
      </td> 
     </tr> 
     </xsl:for-each> 
    </table> 
    </xsl:template> 
</xsl:stylesheet> 

을 시도 할 수 있습니다.

+0

이 답변은이 질문에 대한 것이 었습니까? –

+0

그는 xslt에서 속성 값을 사용해야하기 때문에 그렇게 생각합니다. 디스플레이 출력. 나는 이미이 xslt를 사용하여 거의 동일한 xml 형식의 메뉴를 PHP 및 C#으로 표시했습니다. 이것은 내 requiremnt가 메뉴 html을 표시하기 위해 약간 다르므로 조건이있는 diffent node입니다. 하지만 당신은 귀하의 요구 사항에 따라 partclaur 부품을 얻을 수 있습니다 –

관련 문제