Inserts the value of the selected node as text.
<xsl:value-of select = expression disable-output-escaping = "yes" | "no" </xsl:value-of>
<xsl:text disable-output-escaping="yes"><</xsl:text>
generates the single character "<"
.
Note disable-output-escaping="yes" can be used to generate non-well-formed documents, and thus should be used with caution, since non-well-formed output may generate errors in certain circumstances. For instance, transformNodeToObject to an XML Document requires that the result be well-formed and thus may not complete if disable-output-escaping has affected the well-formedness of the document. We recommend considering disable-output-escaping="yes" as an advanced feature to be used only when the potential dangers are understood.
Number of occurrences | Unlimited |
Parent elements | xsl:attribute, xsl:comment, xsl:copy, xsl:element, xsl:for-each, xsl:if, xsl:otherwise, xsl:param, xsl:processing-instruction, xsl:template, xsl:variable, xsl:when, xsl:with-param, output elements |
Child elements | (No child elements) |
The <xsl:value-of> element inserts a text string representing the value of the first element (in document order) specified by the select attribute.
If the XPath expression returns more than a single node, the <xsl:value-of> element returns the text of the first node returned (equivalent to the XMLDOMNode object's selectSingleNode method). If the node returned is an element with substructure, <xsl:value-of> returns the concatenated text nodes of that element's subtree with the markup removed.
Given this XML,
<?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="family.xsl"?> <family> <person> <given-name age="10">Fred</given-name> <family-name>Smith</family-name> </person> … </family>
the following creates an HTML paragraph from a "person" element with "given-name" and "family-name" child elements. The paragraph will contain the string-value of the first "given-name" child element of the current node, followed by a space and the string-value of the first "family-name" child element of the current node.
<xsl:template match="person"> <p> <xsl:value-of select="given-name"/> <xsl:text> </xsl:text> <xsl:value-of select="family-name"/> </p> </xsl:template>
Creating and Populating an HTML Template