[xquery-talk] query on recursive xml structure

Torsten Grust grust at in.tum.de
Tue Aug 29 12:10:27 PDT 2006


Following up on myself, the slightly modified

           //b[*/text()/tokenize(.," ") = ("kiwi","banana")]

should be more stable with respect to spurious white space in the sub- 
trees below b elements.

    --Torsten

On Aug 29, 2006, 10:44 AM, Torsten Grust wrote with possible deletions:
> Hi,
>
> does
>
>   //b[*/tokenize(.," ") = ("kiwi","banana")]
>
> solve your problem?  (It behaves as desired for the two cases you  
> give below.)
>
> Cheers,
>    --Torsten
>
> On Aug 29, 2006, 10:18 AM, yix yix wrote with possible deletions:
>> Hi,
>>
>>
>> My input document looks like that :
>>
>> <a>
>>     <b n="1">
>>         <c>pea</c>
>>         <d>apple</d>
>>         <b n="2">
>>             <c>kiwi</c>
>>             <d>banana</d>
>>         </b>
>>     </b>
>>     <b n="3">
>>         <c>kiwi</c>
>>         <d>banana</d>
>>     </b>
>> </a>
>>
>> The structure is recursive : b can contain b.
>>
>> I want to write a query to retrieve any b that contains "kiwi" and  
>> "banana", but I want to exclude the first b (with n="1") because  
>> the keywords are not in its own content (c+d), but in its b  
>> child's content.
>> The query should return b2 and b3.
>>
>> This query can't go :
>>
>> for $x in //b
>> where $x[contains(., "kiwi") and contains(., "banana")]
>> and not($x/c[contains(., "kiwi") and contains(., "banana")])
>> return     $x
>>
>> because, sometimes my put could be :
>>
>> <a>
>>     <b n="1">
>>         <c>pea</c>
>>         <d>apple</d>
>>         <b n="2">
>>             <c>kiwi</c>
>>             <d>banana</d>
>>         </b>
>>         <e>kiwi banana</e>
>>     </b>
>>     <b n="3">
>>         <c>kiwi</c>
>>         <d>banana</d>
>>     </b>
>> </a>
>>
>> In that case, the query should return all three b.
>>
>> Thanks for your help,
>>
>> Billig
>> _______________________________________________
>> talk at x-query.com
>> http://x-query.com/mailman/listinfo/talk
>
> --
>   | Prof. Dr. Torsten Grust                         grust at in.tum.de |
>   |                                 http://www-db.in.tum.de/~grust/ |
>   |     Database Systems - Technische Universität München (Germany) |
>
>
>
>
>
> _______________________________________________
> talk at x-query.com
> http://x-query.com/mailman/listinfo/talk
>

--
   | Prof. Dr. Torsten Grust                         grust at in.tum.de |
   |                                 http://www-db.in.tum.de/~grust/ |
   |     Database Systems - Technische Universität München (Germany) |







More information about the talk mailing list