Latest web development tutorials

<: Valor de XSL> elemento XSLT

Manual de XSLT elementos de referencia Manual de XSLT elementos de referencia

Definición y Uso

<Xsl: value-of> puede extraer el valor del nodo seleccionado.

<Xsl: value-of> se puede utilizar para seleccionar el valor de un elemento XML, y la emite.


gramática

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

propiedad

属性 描述
select expression 必需。一个 XPath 表达式,规定了从哪个节点/属性来提取值。它的工作原理与通过正斜杠(/)选择子目录的导航文件系统类似。
disable-output-escaping yes
no
可选。如果值为 "yes",通过实例化 <xsl:text> 元素生成的文本节点在输出时将不进行任何转义。比如 "<" 将输出为 "<"。如果值为 "no",则 "<" 将输出为 "&lt;"。默认是 "no"。


Ejemplos

Los siguientes ejemplos se obtiene el valor de los primeros elementos de título y artista, y se colocan en la tabla:

Ejemplo 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>
<h1>Music Collection:</h1>
<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>

Trate »

En el siguiente ejemplo se recorre cada elemento de cd, y crear una tabla con una fila para cada elemento cd del título y artista de valores:

Ejemplo 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>
<h1>Music Collection:</h1>
<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>

Trate »


Manual de XSLT elementos de referencia Manual de XSLT elementos de referencia