← Back to list

XSLT string functions: complete reference with examples

Alexandre Vazquez · 2026-05-14 09:00 · 0 claps · 1.0 min read
#xslt #xpath #string #function
Open on Medium ↗

String manipulation is one of the most common tasks in XSLT. Whether you are formatting output, parsing codes, or normalising values from external systems, XPath provides a rich set of string functions. This reference covers the most useful ones with examples you can run in XSLT Playground.

Basic string functions (XSLT 1.0+)

string-length

Returns the number of characters in a string.

substring

Extracts a portion of a string. Arguments: string, start position (1-based), optional length.

substring-before and substring-after

Split a string on a delimiter.

contains, starts-with, ends-with

Test membership without extracting.

...
...

...

concat

Joins strings together. Takes any number of arguments.

normalize-space

Strips leading and trailing whitespace, and collapses internal whitespace to single spaces. Essential for cleaning values from XML sources.

translate

Replaces characters one-for-one. Useful for simple case conversion or character removal.

Advanced string functions (XSLT 2.0+)

upper-case and lower-case

No longer need translate for case conversion.

replace

Regex-based substitution. Much more powerful than translate.

matches

Tests a string against a regex.

tokenize

Splits a string into a sequence using a regex delimiter. Returns a sequence of strings.

string-join

The inverse of tokenize. Joins a sequence with a separator.

format-number

Formats a number as a string with a picture pattern.

format-date and format-dateTime

Format xs:date and xs:dateTime values using picture strings.

Practical patterns

Extract domain from URL:

Pad a number with leading zeros:

Check if a node text is numeric:

All of these work in XSLT Playground. Set the version to 2.0 or 3.0 for the functions that require it.


메타데이터
post_id
86ee2725f2c8
slug
xslt-string-functions-complete-reference-with-examples-86ee2725f2c8
url
https://medium.com/@alexandrev/xslt-string-functions-complete-reference-with-examples-86ee2725f2c8
canonical_url
https://medium.com/@alexandrev/xslt-string-functions-complete-reference-with-examples-86ee2725f2c8
author_url
https://medium.com/@alexandrev
status
ok
fetched_at
2026-06-22 05:41:33