Substring function in xslt


Substring function returns the first argument starting at the position specified in the second argument and the length specified in the third argument.
string substring(string, number, number)

Example – 

The following function call returns “456”:
substring(“34567”,2,3)
The following function call returns “234”:
substring(“1234”,2)
The following function returns “sheet”:
substring(“harsheet”,4)

Substring-after

substring-after(string,string)
The substring-after function returns the substring of the first argument string that follows the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.
The following function call returns “99/04/01”:
substring-after("1999/04/01","19")

Substring-before

substring-before(string, string)

Returns the substring of the first argument string that precedes the first occurrence of the second argument string in the first argument string, or the empty string if the first argument string does not contain the second argument string.

The following function call returns “1999”:

substring-before("1999/04/01","/") 
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.