<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD><TITLE>RE: [xquery-talk] Count of Distinct elements performance problem</TITLE>
<META http-equiv=Content-Type content="text/html; charset=us-ascii">
<META content="MSHTML 6.00.2900.2963" name=GENERATOR></HEAD>
<BODY>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><FONT face=Arial 
color=#0000ff size=2>Did you tell us what product you are 
using?</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><FONT face=Arial 
color=#0000ff size=2>As I mentioned, the recursive code depends heavily on 
optimization in the processor - as indeed does everything, with the kind of data 
volumes you are dealing with.</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><FONT face=Arial 
color=#0000ff size=2></FONT></SPAN>&nbsp;</DIV>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><FONT face=Arial 
color=#0000ff size=2>Michael Kay</FONT></SPAN></DIV>
<DIV dir=ltr align=left><SPAN class=657215319-23082006><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@xquery.com 
  [mailto:talk-bounces@xquery.com] <B>On Behalf Of </B>Kusunam, 
  Srinivas<BR><B>Sent:</B> 23 August 2006 19:47<BR><B>To:</B> 
  talk@xquery.com<BR><B>Subject:</B> RE: [xquery-talk] Count of Distinct 
  elements performance problem<BR></FONT><BR></DIV>
  <DIV></DIV>
  <DIV id=idOWAReplyText4495 dir=ltr>
  <DIV dir=ltr><FONT face=Arial color=#000000 size=2>Mike,</FONT></DIV>
  <DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV dir=ltr><FONT face=Arial 
  size=2>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks for the 
  code for grouping. I have fixed this Xquery and now i am getting 
  "java.lang.StackOverflowError" with this approach even on half file (with 
  222500 Model Years). Is there anything wrong with this XQuery or 222500 is too 
  much for it?</FONT></DIV>
  <DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV dir=ltr><FONT face=Arial size=2>Here is the XQuery:</FONT></DIV>
  <DIV dir=ltr><FONT face=Arial size=2></FONT>&nbsp;</DIV>
  <DIV dir=ltr>declare function local:groups($seq as xs:string*, $s as 
  xs:string, $count as xs:integer) {<BR>&nbsp;&nbsp; if 
  (empty($seq))<BR>&nbsp;&nbsp; then &lt;gp value="{$s}" 
  count="{$count}"/&gt;<BR>&nbsp;&nbsp; else<BR>&nbsp;&nbsp;&nbsp;&nbsp; if 
  ($seq[1] eq $s)<BR>&nbsp;&nbsp;&nbsp;&nbsp; then local:groups($seq[position() 
  &gt; 1], $s, $count+1)<BR>&nbsp;&nbsp;&nbsp;&nbsp; else <BR>&nbsp;(&lt;gp 
  value="{$s}" count="{$count}"/&gt;, local:groups($seq[position() &gt; 
  1],&nbsp; $seq[1], 1)) <BR>&nbsp;};</DIV>
  <DIV dir=ltr>&nbsp;</DIV>
  <DIV dir=ltr>let $mdoc := doc('sampleXML.xml')/Body</DIV>
  <DIV dir=ltr>let $sourModelYear := 
  $mdoc/Title/Group/ModelYear<BR>return<BR>&lt;Elements&gt;<BR>&nbsp;&nbsp;&nbsp; 
  &lt;Element name="ModelYear"&gt; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;frequencyDistribution&gt;<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  {<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let $sortedYears 
  :=&nbsp; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  for $dvalue in 
  $sourModelYear<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;order by 
  $dvalue<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;return 
  string($dvalue)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  return&nbsp;&nbsp; 
  <BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  local:groups($sortedYears[position()&gt;1], $sortedYears[1], 
  1)<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  }<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/frequencyDistribution&gt;<BR>&nbsp;&nbsp;&nbsp; 
  &lt;/Element&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  <BR>&nbsp;&lt;/Elements&gt;</DIV>
  <DIV dir=ltr>&nbsp;</DIV></DIV>
  <DIV dir=ltr><BR>
  <HR tabIndex=-1>
  <FONT face=Tahoma size=2><B>From:</B> Michael Kay 
  [mailto:mhk@mhk.me.uk]<BR><B>Sent:</B> Tue 8/22/2006 4:14 PM<BR><B>To:</B> 
  Kusunam, Srinivas; talk@xquery.com<BR><B>Subject:</B> RE: [xquery-talk] Count 
  of Distinct elements performance problem<BR></FONT><BR></DIV>
  <DIV>
  <P><FONT size=2>Something like this:<BR><BR>let $sortedYears :=<BR>&nbsp; for 
  $dvalue in $sourModelYear<BR>&nbsp; order by $dvalue<BR>&nbsp; return 
  string($dvalue)<BR><BR>(: use string() rather than /text() - strings are 
  simpler and likely to be<BR>smaller, and /text() is fragile in the face of 
  comments :)<BR><BR>return<BR>&nbsp; f:groups($sortedYears[position()&gt;1], 
  $sortedYears[1], 1);<BR><BR><BR>declare function f:groups($seq as 
  xs:string()*, $s as xs:string, $count as<BR>xs:integer)<BR>as xs:integer 
  {<BR>&nbsp; if (empty($seq))<BR>&nbsp; then ()<BR>&nbsp; 
  else<BR>&nbsp;&nbsp;&nbsp; if ($seq[1] eq $s)<BR>&nbsp;&nbsp;&nbsp; then 
  f:count-group($seq[position() &gt; 1], $s, $count+1)<BR>&nbsp;&nbsp;&nbsp; 
  else (&lt;gp value="{$s}" 
  count="{$count}"/&gt;,<BR>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  f:count-group($seq[position() &gt; 1], $s, 1))<BR>}<BR><BR>Not 
  tested.<BR><BR>This is likely to perform well if there are a small number of 
  large groups,<BR>less well if there's a large number of small groups - but it 
  depends on how<BR>good the implementation is at recursion.<BR><BR>Michael 
  Kay<BR><A 
  href="http://www.saxonica.com/">http://www.saxonica.com/</A><BR><BR>&gt; 
  -----Original Message-----<BR>&gt; From: Kusunam, Srinivas [<A 
  href="mailto:SKusunam@rlpt.com">mailto:SKusunam@rlpt.com</A>]<BR>&gt; Sent: 22 
  August 2006 20:44<BR>&gt; To: Michael Kay; talk@xquery.com<BR>&gt; Subject: 
  RE: [xquery-talk] Count of Distinct elements<BR>&gt; performance 
  problem<BR>&gt;<BR>&gt; 
  Michael,<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; Thanks 
  a lot for your 
  reply.<BR>&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; I 
  understand what you are suggesting and it is a<BR>&gt; good idea. But I am not 
  clear about doing positional<BR>&gt; grouping. Here is how I am assuming my 
  modified XQuery would like:<BR>&gt;<BR>&gt; let $mdoc := 
  doc('input.xml')/Body<BR>&gt; let $sourModelYEAR := $mdoc/Title/ModelYear 
  return &lt;Elements&gt;<BR>&gt;&nbsp;&nbsp;&nbsp; &lt;Element 
  name="ModelYear"&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;Distribution&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  {<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for 
  $dvalue in $sourModelYEAR/text()&nbsp;&nbsp;&nbsp; ------ Extract<BR>&gt; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; order by 
  $dvalue&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  ------ Sort<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; &nbsp;&nbsp;&nbsp; 
  ............<BR>&gt; &nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; How do we do Grouping of $dvalue 
  i.e.<BR>&gt; ModelYear's (1991, 1992, 1995, 1997 
  etc)????????<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  .............&nbsp;&nbsp; 
  &nbsp;&nbsp;&nbsp;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  return&nbsp;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;distribution&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;value&gt;{ $dvalue 
  }&lt;/value&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;count&gt;{ $eachcount 
  }&lt;/count&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/distribution&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  }<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Distribution&gt;<BR>&gt;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Element&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt;&nbsp; 
  &lt;/Elements&gt;<BR>&gt;<BR>&gt; Thanks,<BR>&gt; Srinivas<BR>&gt;<BR>&gt; 
  -----Original Message-----<BR>&gt; From: Michael Kay [<A 
  href="mailto:mhk@mhk.me.uk">mailto:mhk@mhk.me.uk</A>]<BR>&gt; Sent: Tuesday, 
  August 22, 2006 2:20 PM<BR>&gt; To: Kusunam, Srinivas; talk@xquery.com<BR>&gt; 
  Subject: RE: [xquery-talk] Count of Distinct elements<BR>&gt; performance 
  problem<BR>&gt;<BR>&gt; A performance question like this can only be answered 
  with<BR>&gt; respect to a specific product.<BR>&gt;<BR>&gt; There aren't many 
  XQuery engines that will handle an 8Gb<BR>&gt; file, so you're doing quite 
  well.<BR>&gt;<BR>&gt; You might find that a multi-pass approach works 
  faster:<BR>&gt;<BR>&gt; (a) extract the values<BR>&gt;<BR>&gt; (b) sort 
  them<BR>&gt;<BR>&gt; (c) use a recursive scan to do positional grouping - 
  depends<BR>&gt; on your product supporting tail call 
  optimization<BR>&gt;<BR>&gt;<BR>&gt; That's likely to have O(n*log(n)) 
  performance rather than O(n^2).<BR>&gt;<BR>&gt; Michael Kay<BR>&gt; <A 
  href="http://www.saxonica.com/">http://www.saxonica.com/</A><BR>&gt;<BR>&gt;<BR>&gt;<BR>&gt; 
  &gt; -----Original Message-----<BR>&gt; &gt; From: 
  talk-bounces@xquery.com<BR>&gt; &gt; [<A 
  href="mailto:talk-bounces@xquery.com">mailto:talk-bounces@xquery.com</A>] On 
  Behalf Of Kusunam, Srinivas<BR>&gt; &gt; Sent: 22 August 2006 18:36<BR>&gt; 
  &gt; To: talk@xquery.com<BR>&gt; &gt; Subject: [xquery-talk] Count of Distinct 
  elements<BR>&gt; performance problem<BR>&gt; &gt;<BR>&gt; &gt; I am trying to 
  find count of distinct elements (Model Year).<BR>&gt; &gt; Here is my XQuery. 
  It takes 4 hrs to get the count from 8GB file.<BR>&gt; &gt; There are around 
  3000 distinct Model years in this file.<BR>&gt; &gt;<BR>&gt; &gt; let $mdoc := 
  doc('input.xml')/Body<BR>&gt; &gt; let $sourModelYEAR := $mdoc/Title/ModelYear 
  return &lt;Elements&gt;<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Element 
  name="ModelYear"&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;Distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for $dvalue 
  in fn:distinct-values($sourModelYEAR)<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let 
  $eachcount := count($mdoc/Title[ModelYear=$dvalue])<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  return&nbsp;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;value&gt;{ $dvalue }&lt;/value&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;count&gt;{ $eachcount }&lt;/count&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Distribution&gt;<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Element&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &gt;&nbsp; 
  &lt;/Elements&gt;<BR>&gt; &gt;<BR>&gt; &gt; This Query seems to loop through 
  the document for each value i.e.<BR>&gt; &gt; overall 3000 times. I know this 
  should be easily achievable<BR>&gt; if we have<BR>&gt; &gt; Group-by in 
  XQuery. Do any XQuery engine supports<BR>&gt; &gt; (custom) Group-By 
  now?<BR>&gt; &gt; Or is there any other way to make this query 
  efficient?<BR>&gt; &gt;<BR>&gt; &gt; Where as if I add one more element to 
  find the pattern of<BR>&gt; the data it<BR>&gt; &gt; finishes the job within 
  40 minutes? Why is this odd behavior?<BR>&gt; &gt;<BR>&gt; &gt; let $mdoc := 
  doc('input.xml')/Body<BR>&gt; &gt; let $sourModelYEAR := $mdoc/Title/ModelYear 
  return &lt;Elements&gt;<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; &lt;Element 
  name="ModelYear"&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;Distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; for $dvalue 
  in fn:distinct-values($sourModelYEAR)<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; let 
  $eachcount := count($mdoc/Title[ModelYear=$dvalue])<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  return&nbsp;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;value&gt;{ $dvalue }&lt;/value&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;count&gt;{ $eachcount }&lt;/count&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; }<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Distribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;PatternDistribution&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; {<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  for $phonenum in<BR>&gt; &gt; 
  distinct-values($sourModelYEAR/translate(.,<BR>&gt; &gt; 
  '0123456789','9999999999'))<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  return<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;pattern&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;type&gt;{ $phonenum }&lt;/type&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;count&gt;{count($sourModelYEAR[translate(.,<BR>&gt; &gt; '0123456789', 
  '9999999999') eq $phonenum])}&lt;/count&gt;<BR>&gt; 
  &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/pattern&gt;<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  }<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/PatternDistribution&gt;<BR>&gt; &gt;&nbsp;&nbsp;&nbsp;&nbsp; 
  &lt;/Element&gt;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<BR>&gt; &gt; 
  &lt;/Elements&gt;<BR>&gt; &gt;<BR>&gt; &gt;<BR>&gt; &gt; Thanks,<BR>&gt; &gt; 
  Srini<BR>&gt; &gt; 
  *****************************************************************<BR>&gt; &gt; 
  This message has originated from RLPTechnologies,<BR>&gt; &gt; 26955 
  Northwestern Highway, Southfield, MI 48033.<BR>&gt; &gt;<BR>&gt; &gt; 
  RLPTechnologies sends various types of email communications.&nbsp;<BR>&gt; 
  &gt; If this email message concerns the potential licensing of an RLPT<BR>&gt; 
  &gt; product or service, and you do not wish to receive further emails<BR>&gt; 
  &gt; regarding Polk products, forward this email to 
  Do_Not_Send@rlpt.com<BR>&gt; &gt; with the word "remove" in the subject 
  line.<BR>&gt; &gt;<BR>&gt; &gt; The email and any files transmitted with it 
  are confidential and<BR>&gt; &gt; intended solely for the individual or entity 
  to whom they are<BR>&gt; &gt; addressed.<BR>&gt; &gt;<BR>&gt; &gt; If you have 
  received this email in error, please delete<BR>&gt; this message<BR>&gt; &gt; 
  and notify the Polk System Administrator at postmaster@rlpt.com.<BR>&gt; &gt; 
  *****************************************************************<BR>&gt; 
  &gt;<BR>&gt; &gt;<BR>&gt; &gt; 
  _______________________________________________<BR>&gt; &gt; 
  talk@xquery.com<BR>&gt; &gt; <A 
  href="http://xquery.com/mailman/listinfo/talk">http://xquery.com/mailman/listinfo/talk</A><BR>&gt;<BR>&gt; 
  *****************************************************************<BR>&gt; This 
  message has originated from RLPTechnologies,<BR>&gt; 26955 Northwestern 
  Highway, Southfield, MI 48033.<BR>&gt;<BR>&gt; RLPTechnologies sends various 
  types of email<BR>&gt; communications.&nbsp; If this email message concerns 
  the<BR>&gt; potential licensing of an RLPT product or service, and<BR>&gt; you 
  do not wish to receive further emails regarding Polk<BR>&gt; products, forward 
  this email to Do_Not_Send@rlpt.com<BR>&gt; with the word "remove" in the 
  subject line.<BR>&gt;<BR>&gt; The email and any files transmitted with it are 
  confidential<BR>&gt; and intended solely for the individual or entity to whom 
  they<BR>&gt; are addressed.<BR>&gt;<BR>&gt; If you have received this email in 
  error, please delete this<BR>&gt; message and notify the Polk System 
  Administrator at<BR>&gt; postmaster@rlpt.com.<BR>&gt; 
  *****************************************************************<BR>&gt;<BR>&gt;<BR><BR></FONT></P></DIV><PRE>*****************************************************************
This message has originated from RLPTechnologies,
26955 Northwestern Highway, Southfield, MI 48033.

RLPTechnologies sends various types of email
communications.  If this email message concerns the
potential licensing of an RLPT product or service, and
you do not wish to receive further emails regarding Polk
products, forward this email to Do_Not_Send@rlpt.com
with the word "remove" in the subject line.

The email and any files transmitted with it are confidential
and intended solely for the individual or entity to whom they
are addressed.

If you have received this email in error, please delete this
message and notify the Polk System Administrator at
postmaster@rlpt.com.
*****************************************************************

</PRE></BLOCKQUOTE></BODY></HTML>