XPath expressions can appear either as the contents of an XML element or as the contents of an expr (expression) statement. In either case, the value is translated to an <xsl:text> or <xsl:value-of> element.
You encode strings using quotation marks (single or double). The concatenation operator is underscore (_), as in PERL 6.
In this example, the contents of the <three> and <four> elements are identical, and the content of the <five> element differs only in the use of the XPath concat() function.
- <top> {
- <one>"test";
- <two>"The answer is " _ results/answer _ ".";
- <three>results/count _ " attempts made by " _ results/user;
-
- <four> {
- expr results/count _ " attempts made by " _ results/user;
- }
-
- <five> {
- expr results/count;
- expr " attempts made by ";
- expr results/user;
- }
- <six>results/message;
- }
The equivalent XSLT:
<top>
<one><xsl:text>test</xsl:text></one>
<two><xsl:value-of select='concat("The answer is ",
results/answer, ".")'/></two>
<three><xsl:value-of select='concat(results/count,
" attempts made by ", , results/user)'/></three>
<four><xsl:value-of select='concat(results/count,
" attempts made by ", , results/user)'/></four>
<five>
<xsl:value-of select="results/count"/>
<xsl:text> attempts made by </xsl:text>
<xsl:value-of select="results/user"/>
</five>
<six><xsl:value-of select='results/message'/></six>
</top>