[xquery-talk] if statements within where clauses?

Cindy Girard clm6u at virginia.edu
Wed Jun 14 14:49:08 PDT 2006


I have the following piece of code:
$hits :=
  for $entries in collection($collctn)//tei.2
    let $docname := concat($entries/@id, '.xml')
    let $divs := $entries//div1
    let $text := $entries/text
    where contains($text, $keyword)
      and $entries//classcode = $region
      and $entries//classcode = $gender
      and $entries//classcode = $race
      and $entries/@type = $type
      <doc>{$entries/@type, <ct>-</ct>}</doc>,


and I need to make each 'and $entries...' statement conditional
(if the variable doesn't equal 'all' then it needs to be included,
otherwise, it needs to be left off).
I believe I need to use a concat() to do it, but I can't seem to get
the syntax right.

Should I put the entire hits variable into a concat()?

(if it matters, I'm using berkelydbxml for this)


Cindy Girard
clm6u at virginia.edu

More information about the talk mailing list