The contains() function
Smartsite 7.4 - ...
The contains() XPath 2.0 function returns true if the string arg1 contains arg2 as substring, otherwise false.
| XML |
|
|---|---|
boolean fn:contains(arg1, string arg2) |
|
Parameters:
- arg1: a node reference or string literal.
- string arg2.
Example
| XML |
|
|---|---|
<html xmlns="http://www.w3.org/1999/xhtml"
xmlns:xf="http://www.w3.org/2002/xforms"
xmlns:fn="http://www.w3.org/2005/xpath-functions">
<head>
<title>Example</title>
<xf:model>
<xf:instance>
<data xmlns="">
<alphabet>abcdefghi</alphabet>
</data>
</xf:instance>
</xf:model>
</head>
<body>
<xf:group>
<xf:output value="fn:contains(alphabet, 'b')" />
<xf:output value="fn:contains('abcd', 'b')" />
<xf:output value="fn:contains(alphabet, 'q')" />
<xf:output value="fn:contains('abcd', 'q')" />
</xf:group>
</body>
</html>
|
|
The result will be:
true
true
false
false
true
false
false
Namespace
This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).