XQuery Library for Fuzzy XPath
We can summarize the elements of the implementation as follows:
(1) The deep and down operators become XQuery functions that take as arguments a context node, an XPath expression and the value (a real number in [0,1]) assigned to deep and down, respectively. For combining deep and down an XQuery function is defined having as argument two real values in [0,1]:
(2) Fuzzy versions of Boolean operators and, or have been defined as XQuery functions, each one for each fuzzy logic we have considered (i.e., Product, Łukasiewicz and Gödel):
(3) Operators avg and avg{a,b} have been defined as XQuery functions:
(4) Fuzzy versions of XQuery expressions where and return have been defined.
In order to make transparent to the user the incorporation of RSVs, we have defined a new version of the return expression, called returnF, which transparently carry out the computation of the RSVs of the answers.
Similarly, since XQuery works with a Boolean logic, the introduction of fuzzy versions of the operators, force us to define a new version of the where expression, called whereF, which carry out transparently the computation of the RSVs from fuzzy conditions.
ReturnF has as parameters the context node and an XPath expression: WhereF has as parameters the context node and a fuzzy condition.
(5) Fuzzy versions of comparison operators for XPath expressions have been defined as XQuery functions. Similarly to whereF, comparison operators have been adapted to handle the RSVs:
In order to implement our library in XQuery we have used the XQuery Module available in BaseX processor [16], in particular, we make use of the function eval that makes possible to manipulate XPath expressions. This function is also available for Exist [19] and Saxon [17] processors. For instance, down is defined as follows:
Each fuzzy operator has been defined as a function, for instance, and (Product logic) and or+ (Gödel logic) are defined as follows: