1.3.4 Basic Expression
In addition to location path expressions, there are many other basic expressions including Boolean, equilateral, relationships, and numerical expressions. These expressions can be used in any case where the result object does not require the node set. They are usually used in XPath predicates and various XSLT structures.
XPath supports standard AND / OR Boolean expressions, and each operand of the expression is forcibly converted to the Boolean value.
Equation expression tests whether the two objects are equal, and its operators are = and! =.
The relationship between the relationship expression is compared between the relationship between the two objects, its operator is <=, <,> = and>. The evaluation of the relationship expression is compared by converting the two operands to the numerical value.
The following words define a comparison method of the equation and relationship expression in the relationship expression:
If the two objects compared are a set of nodes, then the comparison result is true and only having one node in the two node sets, and comparing the result of the string value of these two nodes. If an object compared is a node collection and the other is a value, the comparison result is true and only when there is a node in the node collection, and the string value of the node is converted to the numerical value and compared The value is the same. If an object compared is a set of nodes and the other is a string, the comparison result is true and only a node in the node set, and the string value of the node is equal to the other string. If an object compared is a set of nodes and the other is a Boolean type, its comparison result is true and only a node in the node collection, and the function Boolean converts the node into a Boolean type with compared Boolean Type is equal.
When the two compared objects are not a node collection, and operators are = or! =, Then compare such objects, they convert them into common types and then compare them as follows. If there is at least one of the comparison objects, then each of the compared objects is converted into a Boolean type, just like calling the Boolean function. Otherwise, if at least one is a number, then each compared object is converted into a number, just like calling the Number function. Otherwise, both objects are converted into strings, just like calling a string function. = The comparison is true, when and only when the object is equal;! = The comparison is true, and when and only when the object is not equal. The comparison of numbers is in accordance with IEEE 754 standards. Two Boolean types are equal, when they are true or all. Two strings are equal when they are consisting of the same sequence of UCS characters.
When the two compared objects are not a set of nodes, and the operator is <=, <,> = or>, then the object to be compared is converted into a number and compared in accordance with IEEE 754.
Numerical expressions are possible to implement basic mathematical operations, and operators that can be used include: , -, DIV, MOD, *, - (1 yuan operator). Its calculation is obtained after each operand is converted into a value.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- -----------------