<s1 title="XSL value-of">

<p>Often, stylesheets need to grab data from the XML file and rearrange
them in the template results.  The previous examples used template matching
for all processing, but couldn't grab data within the template pattern.
<var/xsl:value-of/> is the main XSL element to grab data from the XML.

<p><var/xsl:value-of/> extracts data with an XPath
<var/select/> expression.  <var/select/> and the template's <var/match/>
pattern use the same syntax, but are used differently.  For a match
pattern, XSL has a current node and chooses the best matching pattern and
its template.  With a select pattern, XSL starts from a node and selects
strings, numbers, or nodes from that node.

<p>The following example uses xsl:value-of to extract the <var/@name/>
attribute to customize the message.  The xsl:value-of adds text
to the output.</p>

<example title='default.xsl'>
&lt;xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform">

&lt;xsl:template match="hello">
  &lt;xsl:text>Hello, &lt;/xsl:text>
  &lt;xsl:value-of select="@name"/>
&lt;/xsl:template>

&lt;/xsl:stylesheet>
</example>

<p>As the following XTP file shows, using xsl:value-of with XML
attributes gives more power to the custom tags.</p>

<example title='hello.xtp'>
Tag attributes: &lt;hello name="Dolly"/>
</example>
<results>
Tag attributes: Hello, Dolly
</results>

<s2 title="StyleScript">

<p>Because xsl:value-of is so common, StyleScript has a special syntax
for it.  $(<var/select/>) will write the text value of the select
pattern to the output.</p>

<example title='default.xsl'>
$template(hello) &lt;&lt;
Hello, $(@text)
>>
</example>

</s2>

<s2 title="Summary">

<ul>
<li>The XPath pattern <var/@attr/> matches tag attributes.
<li><var/xsl:value-of/> extracts values from the XML.
<li><var/&lt;&lt; ... >>/> trims initial and final linefeeds.
<li><var/$(...)/> expands to <var/&lt;xsl:value-of select="..."/&gt;/>
</ul>

</s2>
</s1>
