qexo-general
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qexo-general] Syntax question, probably a silly one


From: Per Bothner
Subject: Re: [Qexo-general] Syntax question, probably a silly one
Date: Tue, 01 Jul 2003 08:29:22 -0700
User-agent: Mozilla/5.0 (Macintosh; U; PPC Mac OS X Mach-O; en-US; rv:1.4) Gecko/20030612

Carol Romanowski wrote:

I have a query as follows:

for $e in document("doc.xml")//PS
let $i := "KB"
where $e//item = $i
return
<product>
  {$e/@name}
  {$e/@URL}
</product>

The element "item" has an attribute called "strength" that I would like to display in the results, but only for items that match "KB". How do I write the statement to get the proper output?

Not sure what the question is, but this might be a solution:

for $e in document("doc.xml")//PS
return
if ($e//item = "KB")
then
<product>
  {$e//item/@strength}
  {$e/@name}
  {$e/@URL}
</product>
else
<product>
  {$e/@name}
  {$e/@URL}
</product>

or:

for $e in document("doc.xml")//PS
return
element product
  { if ($e//item = "KB") then $e//item/@strength else (),
    $e/@name,
    $e/@URL}

Using '$e//item/@strength' looks strength - what if there are multiple nodes that have a strength attribute, which suggests that #e//item is also questionable, but that is a different matter.
--
        --Per Bothner
address@hidden   http://per.bothner.com/






reply via email to

[Prev in Thread] Current Thread [Next in Thread]