[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 22:28:04 PST 2008


  Where Clause and XDT:Untyped Issues
We still don't know what your source data looks like.

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

> -----Original Message-----
> From: Wei, Alice J. [mailto:http://x-query.com/mailman/listinfo/talk] 
> Sent: 02 February 2008 22:12
> To: Michael Kay; 'Torsten Grust'
> Cc: http://x-query.com/mailman/listinfo/talk
> Subject: RE:  Where Clause and XDT:Untyped Issues
> 
> Hi, Michael:
> 
>   Thanks, I did not realize that my <head type="main"> and 
> <head type="sub"> can bring so many of these relevant errors.
> 
>    I have fixed up the code to as follows:
> 
> let $ad := fn:collection("xmldb:exist://db/my")//ad
> let $sorted_result:=
> for $doc in distinct-values($ad)
> where contains($ad/head[@type='sub'],'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>
> 
> This produces no type error issues, but neither does it bring 
> back results.
> 
> If I  change the where clause to where 
> contains($doc,'Baseball'), it brings back something like the 
> one in the following:
> 
> <ad>
> <statistics> Showing Result: 1 / 1</statistics> <ad> <head> 
> <emph rend ="bold deepink">Hostess</emph> is back with new 
> Baseball Cards...to collect and trade with your 
> friends.</head> <p> <emph rend ="bold orange">3 Free Baseball 
> Cards</emph> <emph rend ="bold">on specially marked boxes of 
> HostessR Snack Cakes.</emph> </p> <p>A total of 150 cards. 
> Full of facts. Collect 'em. Trade 'em.</p>
> <p>3 full-color cards printed on the bottom of every 
> specially marked box of Twinkies <emph rend ="sup">R</emph> , 
> Cup Cakes, Suzy Q's <emph rend ="sup">R</emph> , and other 
> mmmmmmmm-delicious Hostess <emph rend ="sup">R</emph> Snacks. 
> </p> <note>RHostess. Twinkies and Suzy Q's are registered 
> trademarks of ITT Continental Baking Co.
> <lb/>
> Offer expires August 31, 1976</note>
> </ad>
> <!--Another duplicate of the <ad>  -->
> </ad>
> 
> Is it possible that I cannot utilize the where clause at all 
> here? Or, do I have to call up using another user-defined function?
> 
> Thanks for your help.
> ======================================================
> Alice Wei
> MIS 2008
> School of Library and Information Science Indiana University 
> Bloomington http://x-query.com/mailman/listinfo/talk ________________________________________
> From: Michael Kay [http://x-query.com/mailman/listinfo/talk]
> Sent: Saturday, February 02, 2008 10:33 AM
> To: 'Torsten Grust'
> Cc: http://x-query.com/mailman/listinfo/talk; Wei, Alice J.
> Subject: RE:  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/



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.