Reputation: 11723
I only recently learned about the curly brace syntax in XSLT, which allows to specify an XPath expression where a string is expected, and its usefulness to concatenate strings.
So, in my XSLT, I replaced all instances of
<entry>
<xsl:attribute name="id" select="concat(@artifactId, '-', @version, '.zip')" />
</entry>
with the much shorter
<entry id="{@artifactId}-{@version}.zip" />
So far so good. But now I was wondering if I could use the same syntax to concatenate the text for a text node.
Example:
<sourceLocation>
<xsl:value-of select="concat($baseURL, '/artifacts/', @artifactId, '-', @version, '.zip')" />
</sourceLocation>
Is there a way to generate this text node using the curly brace syntax instead of concat
in standard XSLT 2.0?
Upvotes: 0
Views: 444
Reputation: 167696
No, not in XSLT 1.0 or 2.0, XSLT 3.0 allows it however, with a setting http://www.w3.org/TR/xslt-30/#text-value-templates, and some implementation like Saxon 9.5 PE or EE already support that:
<sourceLocation>{$baseURL}/artifacts/{@artifactId}-{@version}.zip</sourceLocation>
Upvotes: 1
Reputation: 122394
Not in XSLT 2.0, but it will be possible in XSLT 3.0, where the syntax is referred to as "text value templates" (akin to attribute value templates).
Upvotes: 1