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

xslt教程

XSLT 教程

XSLT 高级

XSLT 参考手册

  • XSLT 实例
  • XSLT generate-id() 函数

    阅读 (2551)

    XSLT generate-id() 函数


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

    定义和用法

    generate-id() 函数返回唯一标识指定节点的字符串值。

    如果指定的节点集是空的,则返回空字符串。如果省略了 node-set 参数,则默认设置为当前节点。


    语法

    string generate-id(node-set?)

    参数

    参数 描述
    node-set 可选。规定要生成唯一 id 的节点集。

    实例 1

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

    <xsl:template match="/">
    <html>
    <body>
    <h3>Artists:</h3>
    <ul>
    <xsl:for-each select="catalog/cd">
    <li>
    <a href="#{generate-id(artist)}">
    <xsl:value-of select="artist" /></a>
    </li>
    </xsl:for-each>
    </ul>
    <hr />
    <xsl:for-each select="catalog/cd">
    Artist: <a name="{generate-id(artist)}">
    <xsl:value-of select="artist" /></a>
    <br />
    Title: <xsl:value-of select="title" />
    <br />
    Price: <xsl:value-of select="price" />
    <hr />
    </xsl:for-each>
    </body>
    </html>
    </xsl:template>

    </xsl:stylesheet>

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


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