当前位置: 首页 > 网络学院 > XML相关教程 > XSL/XSLT > XSLT <xsl:value-of> 元素

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 <xsl:value-of> 元素


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

Definition and Usage
定义和用法

The <xsl:value-of> element extracts the value of a selected node.
<xsl:value-of> 元素的作用是:提取一个指定节点的值。

The <xsl:value-of> element can be used to select the value of an XML element and add it to the output.
<xsl:value-of>元素的作用是:选择一个XML元素的值并将其添加到输出文档中。

Note: The value of the required select attribute contains an XPath expression. It works like navigating a file system where a forward slash (/) selects subdirectories.
注意:必要的select[选择]属性值包含了一个XPath表达式。它的运行方式如同一个文件操作系统,该系统内通过在前面加上斜杠(/)来选择子目录。


Syntax
语法

<xsl:value-of
select="expression"
disable-output-escaping="yes|no"/>

Attributes
属性

属性

描述

select expression Required. An XPath expression that specifies which node/attribute to extract the value from
必要参数。指定一个XPath表达式,该表达式是用于指明从哪个节点/属性中提取值。
disable-output-escaping yes
no
Optional. "yes" indicates that special characters (like "<") should be output as is. "no" indicates that special characters (like "<") should be output as "&lt;". Default is "no"
可选参数。如果设置为"yes",则指定了具体字符(如:“<”)以其本身形式输出;如果设置为"no",则指定了具体字符(如:“<”)必须作为"&lt;"输出。默认为no

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> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <tr> <td><xsl:value-of select="catalog/cd/title"/></td> <td><xsl:value-of select="catalog/cd/artist"/></td> </tr> </table> </body> </html>
</xsl:template>
</xsl:stylesheet>

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

Example 2
案例2

<?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> <h2>My CD Collection</h2> <table border="1"> <tr bgcolor="#9acd32"> <th>Title</th> <th>Artist</th> </tr> <xsl:for-each select="catalog/cd"> <tr> <td><xsl:value-of select="title"/></td> <td><xsl:value-of select="artist"/></td> </tr> </xsl:for-each> </table> </body> </html>
</xsl:template>
</xsl:stylesheet>

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

评论 (0) All

登陆 | 还没注册?