The compare() function
Smartsite 7.4 - ...
The compare() XPath 2.0 function returns -1, 0 or 1, depending on whether arg1 collates before, equal to, or after arg2 according to the Invariant Culture collation.
XML | Copy Code |
---|---|
integer fn:compare(arg1, arg2) |
Parameters:
- arg1: a node reference or literal.
- arg2: a node reference or literal.
Example
XML | Copy Code |
---|---|
<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=""> <tekst1>straße</tekst1> <tekst2>strasse</tekst2> <tekst3>strassen</tekst3> </data> </xf:instance> </xf:model> </head> <body> <xf:group> <xf:output value="fn:compare(tekst1,tekst2)" /> <xf:output value="fn:compare(tekst1,tekst3)" /> <xf:output value="fn:compare('strasse','straße')" /> <xf:output value="fn:compare('strassen','straße')" /> <xf:output value="fn:compare('abc','abc')" /> </xf:group> </body> </html> |
The result will be:
0
-1
-1
0
1
0
Namespace
This function is available within the XPath 2.0 namespace (http://www.w3.org/2005/xpath-functions).