Name
[2.0] ends-with()
Given two strings and an optional collation, returns
true
if the first string ends with the
characters of the second string.
Syntax
xs:booleanends-with(
xs:string?
,xs:string?
)
xs:booleanends-with(
xs:string?
,xs:string?
,$collation as xs:string
)
Inputs
Two strings and an optional name of a collation algorithm. A
collation algorithm defines how characters are compared; to take
an example from the specs, a collation algorithm might define that
the characters ss
and the
German ß
(sharp-s) character
are the same.
Output
Assuming both arguments are not zero-length strings, if the
first string ends with the second, ends-with()
returns the boolean
value true
; otherwise, it
returns false
. If the second
string is a zero-length string, ends-with()
returns true
. If the first string
and the second string are both zero-length
strings, ends-with()
returns true. If the first string is a zero-length string but the
second string is not, ends-with()
returns false
.
Defined in
XQuery 1.0 and XPath 2.0 Functions and Operators section 7.5, “Functions Based on Substring Matching.”
Example
Here’s a short stylesheet that demonstrates how the ends-with()
function works:
<?xml version="1.0" encoding="utf-8"?>
<!-- ends-with1.xsl --> <xsl:stylesheet version="2.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"> <xsl:output method="text"/> <xsl:template match="/"> <xsl:variable name="string1" select="'Have a nice day'"/> <xsl:variable name="string2" select="'Have a nice day!'"/> <xsl:variable name="string3" ...
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.