[XQuery Talk Mailing List Archive Home] [By Date] [By Thread] [By Subject] [By Author] [Recent Entries] [Reply To This Message]

Where Clause and XDT:Untyped Issues

Michael Kay mike at saxonica.com
Sat Feb 2 15:33:12 PST 2008


  Where Clause and XDT:Untyped Issues
What's more, I would expect 

let $ad := fn:collection("xmldb:exist://db/my")//ad

to return a set containing several ad elements. The only way 

contains($ad/head,'Baseball')

can return true is if exactly one of those ad elements has a child called
head - which seems intrinsically rather unlikely. If there's more than one
head element, it fails with a type error; if there are none, it return
false.

Incidentally, it's a common mistake to imagine that contains() is a test for
set membership, rather than a test for the presence of a substring. I
suspect that might be happening here. But who knows.

Michael Kay
http://www.saxonica.com/

> -----Original Message-----
> From: http://x-query.com/mailman/listinfo/talk 
> [mailto:http://x-query.com/mailman/listinfo/talk] On Behalf Of Torsten Grust
> Sent: 02 February 2008 12:48
> To: Torsten Grust
> Cc: http://x-query.com/mailman/listinfo/talk; Wei, Alice J.
> Subject: Re:  Where Clause and XDT:Untyped Issues
> 
> Woops, I should have looked more closely.  $doc is bound to 
> atomic values, not nodes.
> 
> The observation about $ad being invariant in the loop 
> applies, though.  This appears ``fishy'': either all bindings 
> of $doc pass or none at all (you seem to observe the former).
> 
>     --Torsten
> 
> On Feb 2, 2008, at 13:41, Torsten Grust wrote:
> 
> > Hi Alice,
> >
> > it might very well be that
> >
> >  where contains($ad/head,'Baseball')
> >
> > should be replaced by
> >
> >  where contains($doc/head,'Baseball')
> >
> > ($ad is invariant in the loop and thus makes for a 
> questionable filter 
> > criterion).  It is hard to tell, though: as Mike already said, you 
> > didn't post (a sketch of) your data.
> >
> > Cheers,
> >   --Torsten
> >
> >
> > On Feb 1, 2008, at 23:31, Wei, Alice J. wrote:
> >
> >> Hi,
> >>
> >>   I believe I have been passing this question through, but 
> I think my 
> >> main question about not been able to put in a where clause in my 
> >> XQuery after my second let statement has been declared. In 
> return, I 
> >> receive all retrieved results is the issue.
> >>
> >> The code below has been modified from one of the members’  
> >> inspirations.  Apparently, no matter what I do, it appears 
> that the 
> >> where clause in the $sorted_result has never been taken into the 
> >> output generation. When executed the script, it gives me back 
> >> everything, whether or not the word “baseball” was in the head.
> >> I have 197 distinct values in my list.
> >>
> >> let $ad := fn:collection("xmldb:exist://db/my")//ad
> >> let $sorted_result:=
> >> for $doc in distinct-values($ad)
> >> where contains($ad/head,'Baseball')
> >> order by $doc
> >> return $doc
> >> for $r at $count in $sorted_result
> >> let $nodes := $ad[. = $r]
> >> return
> >> <ad>
> >> <statistics>
> >> Showing Result: {$count} / {count($sorted_result)} </statistics> 
> >> {$nodes} </ad>
> >>
> >> What I want here is just something simple, I want to be 
> able to put 
> >> in some form of where clause so I can eliminate more of my current 
> >> result output. [...]
> >
> >
> > -- 
> >  | Prof. Dr. Torsten Grust                         http://x-query.com/mailman/listinfo/talk |
> >  |                                 http://www-db.in.tum.de/~grust/ |
> >  |     Database Systems - Technische Universität München (Germany) |
> >
> >
> >
> >
> > _______________________________________________
> > http://x-query.com/mailman/listinfo/talk
> > http://x-query.com/mailman/listinfo/talk
> 
> -- 
>    | Prof. Dr. Torsten Grust                         http://x-query.com/mailman/listinfo/talk |
>    |                                 http://www-db.in.tum.de/~grust/ |
>    |     Database Systems - Technische Universität München (Germany) |
> 
> 
> 
> 
> _______________________________________________
> http://x-query.com/mailman/listinfo/talk
> http://x-query.com/mailman/listinfo/talk




PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2007 All Rights Reserved.