当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT generate-id() 函数

XSL/XSLT
XSL 语言
XSLT 介绍
XSLT 浏览器
XSLT 转换
<xsl:template>
<xsl:value-of>
<xsl:for-each>
<xsl:sort>
<xsl:if>
<xsl:choose>
<xsl:apply-templates>
XSLT - 客户端
XSLT - 服务器端
XSLT - 编辑XML
XSLT 摘要
XSLT 元素参考
XSLT 函数
XSL 编辑器

XSL/XSLT 中的 XSLT generate-id() 函数


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-03-04   浏览: 241 ::
收藏到网摘: n/a

Definition and Usage
定义和用法

The generate-id() function returns a string value that uniquely identifies a specified node.
generate-id()函数的作用是:返回一个用于独立定义指定节点的字符串。

If the node-set specified is empty, an empty string is returned. If you omit the node-set parameter, it defaults to the current node.
如果指定的节点组为空,那么将返回一个空字符串。如果你忽略了节点组[node-set]参数,那么它将默认为当前节点。


Syntax
语法

string generate-id(node-set?)

Parameters
参数

参数 描述
node-set Optional. Specifies on which node-set to generate a unique id
可选参数。指定产生独立id的节点组

Example 1
案例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 文件以及结果

评论 (0) All

登陆 | 还没注册?