Name
concat()
Takes all of its arguments and concatenates them.
Any arguments that are not strings are converted to strings as if
processed by the string()
function.
Syntax
[1.0] stringconcat(
string
,string
,string*
)
[2.0] xs:stringconcat(
xs:anyAtomicType?
,xs:anyAtomicType?
, ...)
Inputs
Two or more strings. The concat()
function is unique in that
it may have any number of arguments.
[2.0] In XSLT 2.0, the arguments passed
to the concat()
function
can be any atomic type. All of the values are converted to
strings. If any of the arguments is the empty sequence, it is
treated as a zero-length string. It is an error if any argument is
a sequence with a length greater than 1.
Output
The concatenation of all of the input values.
Defined in
[1.0] XPath section 4.2, “String Functions.”
[2.0] XQuery 1.0 and XPath 2.0 Functions and Operators section 7.4, “Functions on String Values.”
Example
We’ll use this XML file to demonstrate how concat()
works:
<?xml version="1.0"?>
<!-- albums.xml -->
<list xml:lang="en">
<title>Albums I've bought recently:</title>
<listitem>The Sacred Art of Dub</listitem>
<listitem>Only the Poor Man Feel It</listitem>
<listitem>Excitable Boy</listitem>
<listitem xml:lang="sw">Aki Special</listitem>
<listitem xml:lang="en-gb">Combat Rock</listitem>
<listitem xml:lang="zu">Talking Timbuktu</listitem>
<listitem xml:lang="jz">The Birth of the Cool</listitem>
</list>
In our stylesheet, we’ll use the concat()
function to create filenames for various HTML files. The filenames are composed ...
Get XSLT, 2nd Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.