<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML xmlns="http://www.w3.org/TR/REC-html40" xmlns:v = 
"urn:schemas-microsoft-com:vml" xmlns:o = 
"urn:schemas-microsoft-com:office:office" xmlns:w = 
"urn:schemas-microsoft-com:office:word" xmlns:m = 
"http://schemas.microsoft.com/office/2004/12/omml"><HEAD>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.6000.16587" name=GENERATOR>
<STYLE>@font-face {
        font-family: Calibri;
}
@font-face {
        font-family: Consolas;
}
@page Section1 {size: 8.5in 11.0in; margin: 1.0in 1.0in 1.0in 1.0in; }
P.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
LI.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
DIV.MsoNormal {
        FONT-SIZE: 11pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: "Calibri","sans-serif"
}
A:link {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlink {
        COLOR: blue; TEXT-DECORATION: underline; mso-style-priority: 99
}
A:visited {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
SPAN.MsoHyperlinkFollowed {
        COLOR: purple; TEXT-DECORATION: underline; mso-style-priority: 99
}
P.MsoPlainText {
        FONT-SIZE: 10.5pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: Consolas; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
LI.MsoPlainText {
        FONT-SIZE: 10.5pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: Consolas; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
DIV.MsoPlainText {
        FONT-SIZE: 10.5pt; MARGIN: 0in 0in 0pt; FONT-FAMILY: Consolas; mso-style-priority: 99; mso-style-link: "Plain Text Char"
}
SPAN.EmailStyle17 {
        COLOR: windowtext; FONT-FAMILY: "Calibri","sans-serif"; mso-style-type: personal-compose
}
SPAN.PlainTextChar {
        FONT-FAMILY: Consolas; mso-style-priority: 99; mso-style-link: "Plain Text"; mso-style-name: "Plain Text Char"
}
.MsoChpDefault {
        mso-style-type: export-only
}
DIV.Section1 {
        page: Section1
}
</STYLE>
<!--[if gte mso 9]><xml>
 <o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
 <o:shapelayout v:ext="edit">
  <o:idmap v:ext="edit" data="1" />
 </o:shapelayout></xml><![endif]--></HEAD>
<BODY lang=EN-US vLink=purple link=blue>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2>You haven't shown the source document so it's difficult to 
diagnose. The only thing that makes me nervous about your code is that you first 
do</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN 
class=994155509-02022008>distinct-values($ad)</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial><FONT 
size=2><FONT color=#0000ff>which atomizes items in $ad, and then you 
do</FONT></FONT></FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN 
class=994155509-02022008>contains($ad/head,'Baseball')</SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2>which looks for children of items in $ad. It's unusual to 
atomize something that has children, which makes me 
suspicious.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2>Michael Kay</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=994155509-02022008><FONT face=Arial 
color=#0000ff size=2>http://www.saxonica.com/</FONT></SPAN></DIV><BR>
<BLOCKQUOTE dir=ltr 
style="PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #0000ff 2px solid; MARGIN-RIGHT: 0px">
  <DIV class=OutlookMessageHeader lang=en-us dir=ltr align=left>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> talk-bounces@x-query.com 
  [mailto:talk-bounces@x-query.com] <B>On Behalf Of </B>Wei, Alice 
  J.<BR><B>Sent:</B> 01 February 2008 22:31<BR><B>To:</B> 
  talk@x-query.com<BR><B>Subject:</B> [xquery-talk] Where Clause and XDT:Untyped 
  Issues<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV class=Section1>
  <P class=MsoNormal>Hi, <o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P class=MsoNormal>&nbsp;&nbsp; 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.<o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P class=MsoNormal>&nbsp;The code below has been modified from one of the 
  members&#8217; inspirations. &nbsp;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 &#8220;baseball&#8221; was in the head. I have 197 distinct values in my 
  list. <o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P class=MsoNormal>let $ad := 
  fn:collection("xmldb:exist://db/my")//ad<o:p></o:p></P>
  <P class=MsoNormal>let $sorted_result:=<o:p></o:p></P>
  <P class=MsoNormal>for $doc in distinct-values($ad)<o:p></o:p></P>
  <P class=MsoNormal>where contains($ad/head,'Baseball')&nbsp;&nbsp; 
  <o:p></o:p></P>
  <P class=MsoNormal>order by $doc<o:p></o:p></P>
  <P class=MsoNormal>return $doc<o:p></o:p></P>
  <P class=MsoNormal>for $r at $count in $sorted_result<o:p></o:p></P>
  <P class=MsoNormal>let $nodes := $ad[. = $r]<o:p></o:p></P>
  <P class=MsoNormal>return<o:p></o:p></P>
  <P class=MsoNormal>&lt;ad&gt;<o:p></o:p></P>
  <P class=MsoNormal>&lt;statistics&gt;<o:p></o:p></P>
  <P class=MsoNormal>Showing Result: {$count} / 
  {count($sorted_result)}<o:p></o:p></P>
  <P class=MsoNormal>&lt;/statistics&gt;<o:p></o:p></P>
  <P class=MsoNormal>{$nodes}<o:p></o:p></P>
  <P class=MsoNormal>&lt;/ad&gt;<o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P class=MsoNormal>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. <o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P class=MsoNormal>Any hints on this would be appreciated.<o:p></o:p></P>
  <P class=MsoNormal><o:p>&nbsp;</o:p></P>
  <P 
  class=MsoPlainText>======================================================<o:p></o:p></P>
  <P class=MsoPlainText>Alice Wei<o:p></o:p></P>
  <P class=MsoPlainText>MIS 2008<o:p></o:p></P>
  <P class=MsoNormal>School of Library and Information Science<o:p></o:p></P>
  <P class=MsoNormal>&nbsp;Indiana University Bloomington <o:p></o:p></P>
  <P class=MsoNormal><A 
  href="mailto:ajwei@indiana.edu">ajwei@indiana.edu</A><o:p></o:p></P></DIV></BLOCKQUOTE></BODY></HTML>