What is the purpose of `<xsl:value-of>` in XSLT?
A
To create new XML elements B
To define templates C
To extract and output the value of a selected node D
To loop through XML nodes
Analysis & Theory
`<xsl:value-of>` selects a node and outputs its text value.
Which attribute must be used with `<xsl:value-of>`?
A
name B
select C
match D
value
Analysis & Theory
The `select` attribute specifies the XPath expression to extract the value.
What will `<xsl:value-of select="title" />` output?
A
The string 'title' B
The value of the `<title>` element C
All child elements of `<title>` D
The name of the element
Analysis & Theory
It selects the `title` child element of the current context node and outputs its text value.
Can `<xsl:value-of>` output multiple node values?
A
Yes, it combines all with commas B
Yes, it outputs them as XML C
No, it only outputs the first node’s string value D
Yes, if you set type="multiple"
Analysis & Theory
`<xsl:value-of>` only returns the string value of the first selected node, not all.
What is the result of `<xsl:value-of select="@price" />`?
A
The text inside a <price> element B
An error, because @price is invalid C
The value of the price attribute D
The name of the attribute
Analysis & Theory
`@price` selects the value of the `price` attribute of the current node.
How would you concatenate two values with `<xsl:value-of>`?
A
<xsl:value-of select="first + last" /> B
<xsl:value-of select="concat(first, last)" /> C
<xsl:value-of name="first last" /> D
<xsl:value-of select="first & last" />
Analysis & Theory
XPath’s `concat()` function is used to combine multiple string values in XSLT.
What happens if the XPath expression in `<xsl:value-of>` does not match any node?
A
An error occurs B
The tag is skipped C
It outputs the XPath query as text D
It outputs an empty string
Analysis & Theory
If no matching node is found, `<xsl:value-of>` simply returns an empty string.