Examples

In order to illustrate the language, let us see some examples of flexible queries in XPath. We will take as input document the one shown in Figure 1.

Figure 1: Input XML document collecting Hotel's information

The example shows a sequence of hotels where each one is described by name and price, proximity to streets (close_to) and provided services (pool and metro -together with distance-). In the example, we assume that document order has the following semantics. The tag close_to specifies the proximity to a given street. However, the order of close_to tags is relevant, and the top streets are closer than the streets at the bottom. In other words, the case:

             hotel_H
                           close_to_street_A
                           close_to_street_A

implies that hotel H is near to both streets A and B, but closer to A than to B. The nesting of close_to has also a relevant meaning. While a given street A can be close to the hotel H, the streets close to A are not necessarily close to the hotel H. In other words, in the case:

             hotel_H
                           close_to_street_A
                                                          close_to_street_A

the street B is near to street A, and street A is close to hotel H, which implies that street B is also close to hotel H, but no so close as street A. H can be situated at the end of street A, and B can cross A at the beginning. We can say, in this case, that B is an adjacent street to H, while A is close to H. This means that when looking for a hotel close to a given street, the highest priority should be assigned to streets close to the hotel, while adjacent streets should be relegated to lower priority. The example has been modeled in order to illustrate the use of structural constraints and fuzzy operators. Particularly, when the user tries to find hotels very close to a given street should provide a high DOWN value and a low DEEP value, whereas in the case the user tries to find hotels in the neighborhood of an street should provide high DEEP and low DOWN.

DEEP and DOWN Examples

Example 1.

In our first example, we focus on the use of DOWN. Let us suppose that the user is interested to find a hotel close to Sol street. This might be his(er) first tentative looking for a hotel. Using crisp XPath (s)he would formulate:

« /hotel[/close_to/text()="Sol"]/@name »

However, it gives the user the set of hotels close to Sol without distinguishing the degree of proximity. The fuzzy version of XPath permits to specify a value of degradation of answers, in such a way that the user reformulates the query as:

«/hotel[[DOWN=0.9]/close_to/text()="Sol"]/@name»

The query specifies that close_to tag is degraded by 0.9 from top to down. In other words, when Sol is found close to a hotel, the position in which it occurs gives a different satisfaction value. In this case, we will obtain:

Fortunately, we have found a hotel (NH) which is very close to Sol, and one (Sheraton) which is a little bit farther from Sol.

Let us remark the previous example and the other examples of the Section show the results in order of satisfaction degree.

Example 2.

Let us suppose now that we are looking for a hotel close to Callao. In this case, we can try to make the same question:

«/hotel[[DOWN=0.9]/close_to/text()="Callao"]/@name»

However, the result is empty. Therefore we can try to relax the query by changing '/' by '//':

«/hotel[[DOWN=0.9]//close_to/text()="Callao"]/@name»

Now, we will find answers, however, we will not be able to distinguish the proximity of the hotels. Our fuzzy version of XPath permits to specify how the solutions are degraded but not only taking into account the order but also the deepness. In other words, there would be useful to give different weights to be a close street, and to be an adjacent street. Therefore we can use the query:

«/hotel[[DEEP=0.5;DOWN=0.9]//close_to/text()="Callao"]/@name»

obtaining the following results:

It seems that Melia is near to Callao, and NH is a little bit farther than Melia.

Example 3.

The use of DEEP combined with DOWN could be considered as the best choice. However, DEEP can be used alone when the user only wants to penalize adja- cency. If we like to search hotels near to Gran Via street, degrading adjacent streets with a factor of 0.5, we can consider the following query (and we obtain the following

«//hotel[[DEEP=0.5]//close_to/text()="Gran Via"]/@name»

We can see that Melia is close to Gran Via, while NH, Hilton and Sheraton are situated in adjacent streets of Gran Via. Tryp is the farthest hotel.

Example 4.

The following table summarizes the results by combining DEEP and DOWN in a single query:

«//hotel[[DEEP=r1;DOWN=r2]//close_to/text()="Gran Via"]/@name»

HOTEL
(A: r1 = 0:1; r2 = 1)
(B: r1 = 0:5; r2 = 0:5)
(C: r1 = 1; r2 = 0:1)
Melia
1
1
1
NH
0.1
0.5
1
Hilton
0.1
0.5
1
Tryp
0.01
0.25
1
Sheraton
0.1
0.25
0.1

While case C only penalizes closeness, case A penalizes adjacency. Case B penalizes both closeness and adjacency.

AVG Examples

Example 5.

Let us suppose that the user is interested in a hotel with pool and metro. The user can formulate the query as follows:

«//hotel[services/pool and services/metro]/@name»

However, while (s)he can find results, there would exist hotels with pool and without metro, and hotels with metro and without pool that are discarded. The user can reformulate the query as follows:

«//hotel[services/pool or services/metro]/@name»

However, the user does not know which hotels have pool and which metro. The user can use the operator avg as follows:

«//hotel[services/pool avg services/metro]/@name»

obtaining the following results:

Using the avg fuzzy operator, the user finds that Melia, Tryp and Sheraton have pool and metro, while NH and Hilton lack on one of them.

Example 6.

Now, let us suppose that the importance of the metro is the double of the importance of the pool. In this case, the user can formulate the query as follows:

«//hotel[services/pool avg{1,2} services/metro]/@name»

obtaining the following results:

We can see in the results that NH and Hilton increase the degree of satisfaction w.r.t. the previous query given that they have metro station.

Example 7.

Let us suppose the user is looking now for hotels giving more importance to the fact that the price of the hotel is lower than 150 euros than to the proximity to Sol street. The user can formulate the query as follows, obtaining the above results:

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

Thresholding Example

Fuzzy conditions return a satisfaction degree in the infinite space of real numbers between 0 and 1. We can take profit of this feature by imposing thresholds to such conditions, thus filtering the set of solutions according to the satisfaction degree. The idea is to formulate queries by directly acting on the satisfaction degrees obtained after evaluating "fuzzy" conditions.

Example 8.

For instance, let us suppose that in the query of example 3, the user looks for hotels in which the degree of proximity to Gran Via street is greater than seventy five per cent (i.e., value 0.75 measured between 0 and 1) then (s)he can formulate the following query, obtaining the following results:

«//hotel[([DEEP=0.5]//close_to/text()="Gran Via") > 0.75]/@name»

Conjunctive/Disjunctive Connective Examples

Example 9.

In the following queries we express the following requirement: hotels near to Gran Via, near to a metro station, having pool, with greater preference (3 to 2) to pool than metro. We will use and+, and and and- which provide distinct levels of exigency, which are demonstrated in the results.

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

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

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

So, in the first case (the least exigent and optimistic) we obtain four hotels (Melia, Sheraton, Hilton and Tryp), as well as in the second case (a little bit more exigent) while third table (the strongest one) lists three candidates (Melia, Tryp and Sheraton). Sheraton and Hilton are degraded using and and and-. This effect would even be more evident when previous conditions are compared with a threshold. For instance, to be greater than 0:25. In such a case and- gives just a single solution: Melia.

izmir escort- cratosslot baymavi vdcasino asyabahis tipobet