中国最全IT社区平台 联系我们 | 收藏本站
华晨云阿里云优惠2

xslt教程

XSLT 教程

XSLT 高级

XSLT 参考手册

  • XSLT 实例
  • XSLT key() 函数

    阅读 (2474)

    XSLT key() 函数


    XSLT 函数参考对象 完整的 XSLT 函数参考对象

    定义和用法

    key() 函数通过使用由 <xsl:key> 元素规定的索引号,从文档中返回节点集。


    语法

    node-set key(string, object)

    参数

    参数 描述
    string 必需。规定 xsl:key 元素的名称。
    object 必需。要搜索的字符串。

    实例 1

    <?xml version="1.0" encoding="ISO-8859-1"?>
    <xsl:stylesheet version="1.0"
    xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

    <xsl:key name="cdlist" match="cd" use="title" />

    <xsl:template match="/">
    <html>
    <body>
    <xsl:for-each select="key('cdlist', 'Empire Burlesque')">
    <p>
    Title: <xsl:value-of select="title" />
    <br />
    Artist: <xsl:value-of select="artist" />
    <br />
    Price: <xsl:value-of select="price" />
    </p>
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>

    </xsl:stylesheet>

    查看 XML 文件查看 XSL 文件查看结果


    XSLT 函数参考对象 完整的 XSLT 函数参考对象
    关闭
    程序员人生