Still working on this.  The order-by statement is the more difficult part,
apparently.  This is what I have so far, but I can see that I may need to
restructure the original document by populating it with a bool (<num>, in
the code below)?

let $keywords := ("keyworda", "keywordb", "keywordc")
for $keyword in $keywords
let $matches := doc('test')/document/item[matches(comment, $keyword, 'i')]
let $num :=
  for $match in $matches
  where $match contains text "(" and where $match contains text ")"
  return
  <num>1</num>
order by $num
return
(
<re>
{subsequence($matches/comment, 1,1),
subsequence($matches/buyer, 1,1)}</re>,
<re>
{subsequence($matches/comment, 2,1),
subsequence($matches/buyer, 2,1)}
</re>
)
_______________________________________________
[email protected]
http://x-query.com/mailman/listinfo/talk

Reply via email to