zoukankan      html  css  js  c++  java
  • 06、xsl中choose进行多条件选择

    一、show.xml文件如下:

    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/xsl" href="style.xsl"?>
    <label_out>
    <!--    三条数据    -->
        <label_people>
            <name>张三</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:for-each select="label_out/label_people">
                            <tr>
                                <td>
                                    <xsl:value-of select="name"/>
                                </td>
    <!--                            多重条件选择判定-->
                                <xsl:choose>
                                    <xsl:when test="age &gt; 19">
                                        <td bgcolor="#ff00ff">
                                            <xsl:value-of select="age"/>
                                        </td>
                                    </xsl:when>
                                    <xsl:otherwise>
                                        <td>
                                            <xsl:value-of select="age"/>
                                        </td>
                                    </xsl:otherwise>
                                </xsl:choose>
                                <td>
                                    <xsl:value-of select="country"/>
                                </td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>

    三、输出效果如下:

  • 相关阅读:
    假期实践
    每周更新学习进度表
    作业三
    作业一
    作业二
    真实感海洋的绘制(一):基于统计学模型的水面模拟方法
    递推方程的求解
    真实感海洋的绘制(二):使用快速傅里叶变换加速波形计算
    "Mathematical Analysis of Algorithms" 阅读心得
    HTML2
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/15001075.html
Copyright © 2011-2022 走看看