<xsl:value-of select=”expression”
disable-output-escaping=”yes” | “no” />
The xsl:value-of element is used to write or display in the result tree a string representation of the value assigned to a specified node. To explain it in another way, this XSLT element causes the value assigned to an XML tag to be displayed as text in the HTML page that we create to display the information in our XML file. There is no limit to the number of xsl:value-of elements that can appear in the code.
However, each xsl:value-of element can only have one node assigned to it and this is accomplished by using the mandatory select attribute. Remember that a node can occur an unlimited number of times in an XML document. (For example, the <phone> … </phone> xml tags in our DevGuru Staff List can be used for each staff member.)
You can use the xsl:for-each element to access each occurrence of a specified node in the order in which they occur in the document. As each occurrence is accessed, you can use the xsl:value-of element to display the value of the current node.
As an example, you can use the xsl:for-each element to access all of the phone numbers in the <phone> … </phone> XML tags in our DevGuru Staff List and then display the numbers using thexsl:value-of element. Additionally, you can use the xsl:sort element to define a sorting key which can be used to sort values.
You can also use the xsl:copy, xsl:copy-of, and xsl:text elements to display values as a string or text.
If the value is not a string, then the value will be converted to a string. (This is done automatically by calling the String function.) If the value is a Boolean, then the string will display as “true” or “false”. If the value is a node-set, then only the first value of the first node in the set is displayed and the values of all other nodes in the set are completely ignored.
This is a self-closing element and it cannot contain any child elements or any content.
The mandatory select attribute assigns the node (by name) to the element. Only one node can be assigned for each occurrence of this element.
disable-output-escaping=”yes” | “no”
The optional disable-output-escaping attribute specifies how special characters should appear in the output string. A yes dictates that special characters should be displayed as is (i.e., a < or >). The default, no, dictates that special characters should NOT be displayed as is (i.e., a < is displayed as <).
Scroll to Top