zoukankan      html  css  js  c++  java
  • 12、xsl中apply-templates中mode用法

    一、show.xml文件如下:

    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/xsl" href="style.xsl"?>
    <label_out>
        <!--    三条数据    -->
        <label_people>
            <name>张1三</name>
            <age>22</age>
            <country>中国</country>
        </label_people>
        <label_people>
            <name>李四</name>
            <age>19</age>
            <country>日本</country>
        </label_people>
        <label_people>
            <name>王五</name>
            <age>20</age>
            <country>朝鲜</country>
        </label_people>
    </label_out>

    二、style.xsl文件如下:

    <?xml version="1.0" encoding="GB2312"?>
    <xsl:stylesheet version="1.0"
                    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
    
        <xsl:template match="/">
            <html>
                <body>
                    <h2>抬头内容</h2>
                    <table border="1">
                        <tr bgcolor="#9acd32">
                            <th>姓名</th>
                            <th>年级</th>
                            <th>国家</th>
                        </tr>
                        <!--                    内容-->
                        <xsl:apply-templates select="label_out/label_people" mode="a1"/>
                        <xsl:apply-templates select="label_out/label_people" mode="a2"/>
                    </table>
                </body>
            </html>
        </xsl:template>
    
        <xsl:template match="label_people" mode="a1">
            <tr>
                <td><xsl:value-of select="name"/></td>
                <td><xsl:value-of select="age"/></td>
                <td><xsl:value-of select="country"/></td>
            </tr>
        </xsl:template>
        <xsl:template match="label_people" mode="a2">
            <tr bgcolor="999999">
                <td><xsl:value-of select="name"/></td>
                <td><xsl:value-of select="age"/></td>
                <td><xsl:value-of select="country"/></td>
            </tr>
        </xsl:template>
    
    </xsl:stylesheet>

    三、输出效果如下:

  • 相关阅读:
    javascript的严格模式:use strict
    Ionic在线打包IOS平台应用
    安装nodejs6.9x以后,原来在nodejs4.2.x中运行正常的ionic项目出现问题的解决
    cordova插件分类
    ionic 启用sass
    ngCordova
    为Asp.net WebApi 添加跨域支持
    使用ionic framework创建一个简单的APP
    研究主题
    近两天让我羞愧难当的遭遇
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/15001144.html
Copyright © 2011-2022 走看看