zoukankan      html  css  js  c++  java
  • xslt实现递归

    xml文件如下

    <?xml version="1.0" encoding="utf-8"?>
    <?xml-stylesheet type='text/xsl' href='三级子表.xsl'?>
    <xmldata ver='1.0'>
      <property>
        <segdaysale1st title='类别列表'>
          <segdaysale2nd title='中类类别列表'>
            <segdaysale3rd title='小类类别列表'></segdaysale3rd>
          </segdaysale2nd>
        </segdaysale1st>  
      </property>

    </xmldata>

    xslt文件如下

    <?xml version="1.0" encoding="utf-8"?>
    <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
        <xsl:template match="/">
            <html>
                <body>
                    <ul>
                        <xsl:call-template name="foreachProperty">
                            <xsl:with-param name="nodes" select="xmldata/property/child::*"/>
                        </xsl:call-template>
                    </ul>
                </body>
            </html>   
        </xsl:template>

        <!-- 遍历所有的property -->
        <xsl:template name="foreachProperty">
            <xsl:param name="nodes"/>
            <xsl:for-each select="$nodes">
                <li>
                    <xsl:value-of select="attribute::title"/>                
                </li>                                                                      
                <xsl:if test="child::*">
                <ul>
                    <xsl:call-template name="foreachProperty">
                        <xsl:with-param name="nodes" select="child::*"/>
                    </xsl:call-template>
                </ul>
                </xsl:if>
            </xsl:for-each>
        </xsl:template>     
    </xsl:stylesheet>


     

  • 相关阅读:
    BZOJ.2199.[USACO2011 Jan]奶牛议会(2-SAT)
    BZOJ.1997.[HNOI2010]Planar(2-SAT)
    POJ.3648.Wedding(2-SAT)
    POJ.3678.Katu Puzzle(2-SAT)
    POJ.3207.Ikki's Story IV-Panda's Trick(2-SAT)
    洛谷.4180.[模板]次小生成树Tree(Kruskal LCA 倍增)
    BZOJ.4766.文艺计算姬(Prufer)
    zabbix 微信告警机制
    网络地址
    tcp与udp的区别
  • 原文地址:https://www.cnblogs.com/kuailewangzi1212/p/1799011.html
Copyright © 2011-2022 走看看