Examples of Fuzzy XPath in XQuery

Now, we show how the previous fuzzy XPath queries can be written in XQuery. Let us now suppose the following fuzzy XPath query:

<< /hotels/hotel[[DOWN = 0.9]close_to/text() = "Sol"]/@name >>

We can now write the same query in XQuery as follows:

We can see that fuzzy XPath expressions are written as XQuery expressions. This is the same kind of transformation from crisp XPath to XQuery. For instance:

<< /hotels/hotel[close_to/text() = "Sol"]/@name >>

can be translated into:

In the fuzzy case, “=” is transformed into equalF, and where as well as return become XQuery functions, with an extra argument to represent the context node. The query makes use of the function down of the library to compute the RSVs associated to close_to. In addition, the attribute rsv, which has been (internally) added to the output document, can be handled to show the answer in a sorted way, and even to define a threshold. Let us now consider the following query, that uses deep and down:

<< /hotels/hotel[[DEEP = 0.5;DOWN = 0.9]//close_to/text() = "Callao"]/@name >>

We can now write the same query in XQuery using the function deep_down:

Let us now suppose the following fuzzy XPath expression that makes use of the avg operator.

<< //hotel[services/pool avg services/metro]/@name >>

Here, we use the function avg of the library, having as parameters both sides of the fuzzy condition:

The same can be said for the following query, using avg{a,b} having as parameters a and b.

<< //hotel[services/pool avg{1,2} services/metro]/@name >>

Let us now suppose the following query that combines deep and avg, and deep and and+, respectively:

<< //hotel[[DEEP = 0.8]//close_to/text() = "Sol" avg{1,2} //price/text() < 150]/@name >>

<< //hotel[([DEEP = 0.5]//close_to/text() = "Gran Via") and+ (//pool avg{3,2} //metro/text() < 200)]/@name >>

 

Benchmarks

Now, we would like to show the benchmarks we have obtained using our library. We have tested our library using data sets of different sizes. We have used as data sets traces of execution of MALP programs developed under our FLOPER tool. The FLOPER tool generates traces in XML format and with a high degree of tag nesting when a recursive program is executed. These data sets facilitate the testing of our structural based operators deep and down. We have compared the execution times for two XPath expressions in crisp and fuzzy versions. The first is Q1: « //node/goal », and the second Q2: « //node[goal[contains(text(),"p(")] and substitution[contains(text(),"g(")]]//goal ». We have used the BaseX Query processor in a Intel Core 2 Duo 2.66 GHz Mac OS machine. In Figure 4 we can see the results. We can conclude from the benchmarks that the introduction of the fuzzy component in XPath leads to reasonable overhead costs.

 

Query 16Kb 700Kb 8Mb 15.4Mb
Q1
down in Q1
deep in Q1
deep and down in Q1
Q2
avg in Q2
7.09 ms
12.52 ms
10.08 ms
69.97 ms
5.77 ms
36.59 ms
25.47 ms
107.1 ms
74.17 ms
102.0 ms
57.96 ms
1266.99 ms
123.66 ms
481.24 ms
510.74 ms
685.87 ms
172.03 ms
9729.49 ms
461.6 ms
2853.36 ms
1953.31 ms
7315.59 ms
529.18 ms
60426.28 ms

 

izmir escort- cratosslot baymavi vdcasino asyabahis tipobet