zoukankan      html  css  js  c++  java
  • 03、xsl中添加筛选条件

    一、show.xml文件如下:

    <?xml version="1.0" encoding="GB2312"?>
    <?xml-stylesheet type="text/xsl" href="style.xsl"?>
    <label_out>
    <!--    三条数据    -->
        <label_people>
            <name>张三</name>
            <age>18</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>
                        <!--                    通过for循环输出内容-->
                        <!--                    = (等于)-->
                        <!--                    != (不等于)-->
                        <!--                    &lt; (小于)-->
                        <!--                    &gt; (大于)-->
                        <xsl:for-each select="label_out/label_people[age &gt;= 19]">
                            <tr>
                                <td>
                                    <xsl:value-of select="name"/>
                                </td>
                                <td>
                                    <xsl:value-of select="age"/>
                                </td>
                                <td>
                                    <xsl:value-of select="country"/>
                                </td>
                            </tr>
                        </xsl:for-each>
                    </table>
                </body>
            </html>
        </xsl:template>
    </xsl:stylesheet>

    三、输出效果如下:

  • 相关阅读:
    mybatis与spring的整合(代码实现)
    使用maven构建一个web项目
    解决maven 找不到指定路径应该如何
    建一个maven项目
    spring xml的配置
    mybatis.xml和mapper.xml的配置
    mvc @helper 创建用户自定义html
    sqlserver CLR sqlserver使用C# dll
    索引碎片
    压缩数据库
  • 原文地址:https://www.cnblogs.com/tianpan2019/p/15001031.html
Copyright © 2011-2022 走看看