The substring() function
Smartsite 7.4 - ...
The substring() XPath 2.0 function returns the portion of the value sourcestring beginning at the position indicated by the value of start (1-based) and continuing for the number of characters indicated by the value of length. When length is omitted, the remainder of the string, beginning at the specified start position, is returned.
XML | Copy Code |
---|---|
string fn:substring(sourcestring, double start, double length) string fn:substring(sourcestring, double start) |
Parameters:
- sourcestring: a node reference or string literal.
- start: the start position.
- length: the length (optional).
Example
XML | Copy Code |
---|---|
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xf="http://www.w3.org/2002/xforms" xmlns:exf="http://smartsite.nl/namespaces/xforms/1.0" xmlns:fn="http://www.w3.org/2005/xpath-functions"> <head> <title>Example</title> <xf:model> <xf:instance> <data xmlns=""> <tekst>www.formulierenserver.nl</tekst> </data> </xf:instance> </xf:model> </head> <body> <xf:group> <xf:output value="fn:substring('motor-car', 7)" /> <xf:output value="fn:substring('metadata', 5, 4)" /> <xf:output value="fn:substring(tekst, 5)" /> </xf:group> </body> </html> |
The result will be:
car
data
formulierenserver.nl
formulierenserver.nl
data
formulierenserver.nl
formulierenserver.nl
Namespace
This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).