[xquery-talk] Using Every Clause?

Wei, Alice J. ajwei at indiana.edu
Wed Apr 16 11:14:06 PDT 2008


Hi, XQueriers:

  I have a query as follows:

  declare function local:searchresult($seq as element()*) as element()*
{
let  $sorted_result:=
        for $doc in distinct-values($seq)
        order by $doc
        return $doc
return
for $d at $count in $sorted_result
let $head := $seq[.=$d][1]/ancestor::ad/child::head
let $para := $seq[.=$d][1]/ancestor::ad/(descendant::div|descendant::p)
return
<div>
<p>Showing Result: <b>{$count} / {count($sorted_result)}</b></p>
<p style="font-weight:bold">{$head}&#160; {$head2}&#160; {$head3}</p>
{$para}
</div>
};
let $a := collection("mycollection")//my//head[contains(upper-case(.),'MARKET')]
return
local:searchresult($a)

Functionally, this query works but I don't want the way it gives me the way it presents the HTML output. This initially is not a problem with the XML output format.
Is it possible that I could do something like:

<div>
<p style="font-weight:bold">
<head>Market Place</head>
    </p>
<p>for rates write to Classified, 100 E. Ohio Chi</p>
<div>
<p style="font-style:bold">Vitamins</p>
<p style="font-weight:bold">Discount Vitamins. </p>
<p> "E" 400 I.U. 100--$1.98.   Free catalog. </p>
</div>
<!----more ads-->
</div>

using the input below:

<ad>
<p style="font-weight:bold">
<head>Market Place</head>
    </p>
<p>for rates write to Classified, 100 E. Ohio Chi</p>
<div>
        <head>
<emph rend="bold">Vitamins</emph>
</head>
        <list>
        <item>
<emph rend="bold">Discount Vitamins.</emph>
 "E" 400 I.U. 100--$1.98.   Free catalog.  </item>
</list>
</div>
</ad>

instead of having all the description at the end of the query output?

Thanks to those who can help.

Aliceeeeeeeeeeeeeeeeee
======================================================
Alice Wei
MIS 2009
School of Library and Information Science
Indiana University Bloomington
ajwei at indiana.edu



More information about the talk mailing list