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

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 key() 函数


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

Definition and Usage
定义和用法

The key() function returns a node-set from the document, using the index specified by an <xsl:key> element.
key() 的作用是:使用由<xsl:key> 元素指定的index[索引],从当前文档中返回一个节点组。


Syntax
语法

node-set key(string, object)

Parameters
参数

参数 描述
string Required. Specifies the name of an xsl:key element
必要参数。指定“xml:key element”的名称
object Required. A string to search for
必要参数。指定需要被搜索的字符

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: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 文件以及结果

评论 (0) All

登陆 | 还没注册?