Hi,
You don't have to have two different if-then-elses for the start and end
tag, you can just do it in one go, like below. You also had an extra
"return", and need to have { } around the FLWOR expression within the
DtsResult element. You were also missing a } before the </Trace>
for $x in doc ($doc_name)/ProcessValueTrace/Trace
return
<Trace>
{
for $y in $x/DtsResult
let $bb:=for $xx in $y/DtsRequest where (contains($xx/PDU,
string($pdu_byte_pattern))) return $xx
return
(: my problem is from here down. i have 3 outputs - first the beginning
tag and a few tags i just output

if (empty($bb)) then
""
else
<DtsResult>
{ $y/LogicalLink }
{ $y/ComPrimitive }
(: than i output some selected tags

{for $z in $y/DtsRequest
where (contains($z/PDU, string($pdu_byte_pattern)))
return
$z}
</DtsResult>
}</Trace>
That last FLWOR expression can also be just {$bb}, since it is the same
thing, as in:
<DtsResult>
{ $y/LogicalLink }
{ $y/ComPrimitive }
{ $bb }
</DtsResult>
Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
Coming soon: Definitive XQuery
http://www.datypic.com
----------------------------------
*** Sent via Developersdex
http://www.developersdex.com ***