473,395 Members | 1,452 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

XQuery how to keep order of elements?

I have a element "v" wich has different types of objects a,b,c.

and i do:
for $x in $doc/v/a where ... return $x
for $x in $doc/v/b where ... return $x
for $x in $doc/v/c where ... return $x
for each of them to filter them by conditions.
This way i get all the objects of type a, than all objects of type b,
than all obj of type c.

But I would like to have them in the original (mixed) order.
How to keep this order. Someone told me I could add a order by field.
But still I have to say "for each element whatever type, if it is of
type a than, else..". How do I say this in Xquery?

Paul

Dec 6 '05 #1
7 1261
Hi Paul,

You've got (at least) 2 choices. You can process them all together in
one FLWOR expression, as in:

for $x in $doc/v/(a|b|c) where ... return $x

That will process them in the order they appear in the document. If you
want to do something different with each of the 3 element types, you
could put an "if" expression in your where and/or return clauses to
check if it's a, b or c, as in:

if ($x instance of element(a))
then (: something :)
else if ($x instance of element(b))
then (: something :)
else if ($x instance of element(c))
then (: something :)
else ()

A slightly more compact alternative to that is the typeswitch
expression:

typeswitch($x)
case element(a) return (: something :)
case element(b) return (: something :)
case element(c) return (: something :)
default return (: something :)
Another alternative for keeping document order is to keep the 3 separate
FLWOR expressions and sort them back into document order outside the
scope of those, e.g.

let $all :=
(for $x in $doc/v/a where ... return $x,
for $x in $doc/v/b where ... return $x,
for $x in $doc/v/c where ... return $x)
return $all/.

This will only work if you are actually returning the a, b and c
elements, not their text content or children or whatever. The "/." in
the return clause causes the processor to automatically sort the
elements back to document order.

An order by clause won't help you here - that's only for sorting on the
contents of an element or attribute.

Hope that helps,
Priscilla
----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
Definitive XQuery
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Dec 7 '05 #2
Priscilla,

Thanks for the reply. I'll check out the code.
I'm glad someone answered so I 'm going to ask you to just 2 more
things:
- I want to search by for example
"a*b" and foudn results could be ab, acb, acdefb. What is the closest
regular expersion for * that i can use in match, or contains to do
this.

And now a delicate problem:
I can't get the syntax right. It seems ok but I still get errors.
The return ..<a>.. else.. for.. return stuff are reported as "invalid
tokens".
I just want to do a if else in a for with for inside but the syntax is
tricky. I tried a lot of posiblities.
for $x in $doc

if ($x resp condition) then
<a>
{
for $y in $x/Son
return $y;
}
</a>
else
<b>
{
for $y in $x/Son2
return $y;
}
</b>

Paul

Dec 7 '05 #3
Hi Paul,

1. a.*b should match your examples. Only the "matches" function will use
regexes, not the "contains" function.

2. You are missing a return for the first for, and the semicolons should
not be there. So, if you change it to:

for $x in $doc
return
if ($x resp condition) then
<a>
{
for $y in $x/Son
return $y
}
</a>
else
<b>
{
for $y in $x/Son2
return $y
}
</b>

I assume "$x resp condition" is your shorthand and not your actual
expression that appears there.

Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
Definitive XQuery
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Dec 7 '05 #4
OK. Thanks.

Btw, you are an author, you must know all the tircks in the book. How
should you do "xor"?
I have a big condition (exclude_items=0 and .. (big condition) ) and
for (exclude_items=1 and (big condition)). How should I do this without
placing the huge condition (
pages) twice?

Paul

Dec 8 '05 #5
Hi,

You could assign the big condition to a variable using a let clause, as
in:

let $cond := (big condition)
return
if ((exclude_items = 0 and $cond) or
(exclude_items = 1 and not($cond)))
then ...
else ...
Hope that helps,
Priscilla

----------------------------------
Priscilla Walmsley
Author, Definitive XML Schema
http://www.datypic.com
----------------------------------

*** Sent via Developersdex http://www.developersdex.com ***
Dec 9 '05 #6
Priscilla,

You've been so helpfull.
1)I tried to apply the "typeswitch " thing you showed me but it's now
working.
I have syntax problems when it comes to if (cond) return $x.
Here is my code. You don't have to understand it just please look at
the typeswitch ($y) case element(..) if (cond) then $x else ( )
From a working code I just changed "for .. where .." to "case elment

(..) return if (....) then .. else..". So for each case element the
"return if " sintax is the problem.
2)Also can you give me a complete short example on a sample xml of the
condition negation with "let" you wrote about in the last email.

let $doc_name:="can.xml"
let $exclude_items:=0
let $after_startstoptrace:=0
let $after_comprimitive_logicallink_name:=0
let $after_comprimitive_name:=0
let $after_comprimitive_id:=0
let $logical_link_name:="CAN1.DiagCan"
let $include_complete_result_pdu_request:=0
let $include_complete_result_parameter_value_request:= 0
let $include_complete_result_parameter_type_request:=0
let $include_complete_result_parameter_name_request:=0
let $include_complete_result_error_code_request:=0
let $include_complete_result_error_severity_request:=0
let $include_complete_result_pdu_response:=0
let $include_complete_result_parameter_value_response: =0
let $include_complete_result_parameter_type_response:= 0
let $include_complete_result_parameter_name_response:= 0
let $include_complete_result_error_code_response:=0
let $include_complete_result_error_severity_response:= 0
let $include_complete_result_pdu_both:=0
let $include_complete_result_parameter_value_both:=0
let $include_complete_result_parameter_type_both:=0
let $include_complete_result_parameter_name_both:=0
let $include_complete_result_error_code_both:=0
let $include_complete_result_error_severity_both:=0
let $request_pdu:=0
let $request_parameter_value:=0
let $request_parameter_type:=0
let $request_parameter_name:=1
let $request_error_code:=0
let $request_error_severity:=0
let $response_pdu:=0
let $response_parameter_value:=0
let $response_parameter_type:=0
let $response_parameter_name:=0
let $response_error_code:=0
let $response_error_severity:=0
let $both_pdu:=0
let $both_parameter_value:=0
let $both_parameter_type:=0
let $both_parameter_name:=0
let $both_error_code:=0
let $both_error_severity:=0

let $comprimitive_name:="readDataByLocalID"
let $comprimitive_id:=""
let $pdu_byte_pattern_request:="8"
let $parameter_name_request:="$diagnosticMode^"
let $parameter_type_request:=""
let $parameter_value_request:=""
let $error_code_request:=""
let $error_severity_request:="w"
let $pdu_byte_pattern_response:=""
let $parameter_name_response:=""
let $parameter_type_response:="3"
let $parameter_value_response:=""
let $error_code_response:=""
let $error_severity_response:="w"
let $pdu_byte_pattern_both:=""
let $parameter_name_both:=""
let $parameter_type_both:="3"
let $parameter_value_both:=""
let $error_code_both:=""
let $error_severity_both:="w"

for $x in doc ($doc_name)/ProcessValueTrace/Trace
return

<ProcessValueTrace> <Trace>

{for $y in
$x/(StartTrace|OpenComPrimitive|DtsResult|CloseComPri mitive|StopTrace)
return
typeswitch($y)
case element(StartTrace)
return
if( $after_startstoptrace=1 and $exclude_items=0) then
(: sintax problem here :)
return $y
else ()

case element(OpenComPrimitive)
return

if(
($exclude_items=0 and
($after_comprimitive_logicallink_name=1 or $after_comprimitive_name=1
or
$after_comprimitive_id=1) and

(
( $after_comprimitive_logicallink_name=0 or
($ after_comprimitive_logicallink_name=1 and
(
some $z in $y/LogicalLink satisfies
(
contains($z/ShortName, string($logical_link_name))
)
)
)
)
and
( $after_comprimitive_name=0 or
($ after_comprimitive_name=1 and
(
contains($y/ShortName, string($comprimitive_name))
)
)
)
and
( $after_comprimitive_id=0 or
($ after_comprimitive_id=1 and
(
contains($y/ID, string($comprimitive_id))
)
)
)
)
)
) then
(: sintax problem here :)
return $y
else ()

case element(DtsResult)
return
{
if
(
(

(: start include complete conditions in DtsResult :)
(
($include_complete_result_pdu_request=1 and
( ($request_pdu=1)
and
(
some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_request))
)
)
)
)

or
($include_complete_result_parameter_name_request=1 and
( ($request_pdu=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
matches($xx/ShortName, string($parameter_name_request))
)
)
)
)

or
($include_complete_result_parameter_value_request= 1 and
( ($request_parameter_value=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Value, string($parameter_value_request))
)
)
)
)

or
($include_complete_result_parameter_type_request=1 and
( ($request_parameter_type=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Type, string($parameter_type_request))
)
)
)
)

or
($include_complete_result_error_code_request=1 and
( ($request_error_code=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/CodeDescription, string($error_code_request))
)
)
)
)
or
($include_complete_result_error_severity_request=1 and
( ($request_error_severity=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/Severity, string($error_severity_request))
)
)
)
)
or
($include_complete_result_pdu_response=1 and
( ($response_pdu=1)
and
(
some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_response))
)
)
)
)

or

($include_complete_result_parameter_name_response= 1 and
( ($response_pdu=1)
and
(
some $xx in $y/DtsResponse/DtsReponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_response))
)
)
)
)

or
($include_complete_result_parameter_value_response =1 and
( ($response_parameter_value=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_response))
)
)
)
)
or
($include_complete_result_parameter_type_response= 1 and
( ($response_parameter_type=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_response))
)
)
)
)
or
($include_complete_result_error_code_response=1 and
( ($response_error_code=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_response))
)
)
)
)
or
($include_complete_result_error_severity_response= 1 and
( ($response_error_severity=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_response))
)
)
)
)
or
($include_complete_result_pdu_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
and
(some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
)
)
)
or
($include_complete_result_parameter_name_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
)
)
)
or
($include_complete_result_parameter_value_both=1 and
( ($both_parameter_value=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
)
)
)
or
($include_complete_result_parameter_type_both=1 and
( ($both_parameter_type=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
)
)
)

or
($include_complete_result_error_code_both=1 and
( ($both_error_code=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
)
)
)
or
($include_complete_result_error_severity_both=1 and
( ($both_error_severity=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
)
)
)
)(: end include complete conditions in DtsResult :)
or
(
(: start all non complete conditions in DtsResult :)

(: we must have some conditions :)
($request_pdu=1 or $request_parameter_name=1 or
$request_parameter_type=1 or
$request_parameter_value=1 or $request_error_code=1 or
$request_error_severity=1
or
$response_pdu=1 or $response_parameter_name=1 or
$response_parameter_type=1 or
$response_parameter_value=1 or $response_error_code=1 or
$response_error_severity=1
or
$both_pdu=1 or $both_parameter_name=1 or $both_parameter_type=1 or
$both_parameter_value=1 or $both_error_code=1 or
$both_error_severity=1)
and
($include_complete_result_pdu_request=1 or
($include_complete_result_pdu_request=0 and
(
($request_pdu=0 or
($request_pdu=1
and
(
some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_request))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_name_request=1 or
($include_complete_result_parameter_name_request=0 and
(
($request_parameter_name=0 or
($request_parameter_name=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_request))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_request= 1 or
($include_complete_result_parameter_value_request= 0 and
(
($request_parameter_value=0 or
($request_parameter_value=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_request))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_type_request=1 or
($include_complete_result_parameter_type_request=0 and
(
($request_parameter_type=0 or
($request_parameter_type=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_request))
)
)
)
)
)
)
)
and
($include_complete_result_error_code_request=1 or
($include_complete_result_error_code_request=0 and
(
($request_error_code=0 or
($request_error_code=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_request))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_request=1 or
($include_complete_result_error_severity_request=0 and
(
($request_error_severity=0 or
($request_error_severity=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_request))
)
)
)
)
)
)
)

and
($include_complete_result_pdu_response=1 or
($include_complete_result_pdu_response=0 and
(
($response_pdu=0 or
($response_pdu=1
and
(
some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_response))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_name_response= 1 or
($include_complete_result_parameter_name_response= 0 and
(
($response_parameter_name=0 or
($response_parameter_name=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_response))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_response =1 or
($include_complete_result_parameter_value_response =0 and
(
($response_parameter_value=0 or
($response_parameter_value=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_response))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_type_response= 1 or
($include_complete_result_parameter_type_response= 0 and
(
($response_parameter_type=0 or
($response_parameter_type=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_response))
)
)
)
)
)
)
)
and
($include_complete_result_error_code_response=1 or
($include_complete_result_error_code_response=0 and
(
($response_error_code=0 or
($response_error_code=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_response))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_response= 1 or
($include_complete_result_error_severity_response= 0 and
(
($response_error_severity=0 or
($response_error_severity=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_response))
)
)
)
)
)
)
)
and
($include_complete_result_pdu_both=1 or
($include_complete_result_pdu_both=0 and
(
($response_pdu=0 or
($response_pdu=1
and
(
(some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
and
(some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
)
)
)
)
)
)
and
($include_complete_result_parameter_name_both=1 or
($include_complete_result_parameter_name_both=0 and
(
($response_parameter_name=0 or
($response_parameter_name=1
and
(
(some $xx in $y/DtsResponse/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
and
(some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
)
)
)
)
)
)
and
($include_complete_result_parameter_value_both=1 or
($include_complete_result_parameter_value_both=0 and
(
($response_parameter_value=0 or
($response_parameter_value=1
and
(
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
and
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
)
)
)
)
)
)
and
($include_complete_result_parameter_type_both=1 or
($include_complete_result_parameter_type_both=0 and
(
($response_parameter_type=0 or
($response_parameter_type=1
and
(
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
and
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))

)
)
)
)
)
)
and
($include_complete_result_error_code_both=1 or
($include_complete_result_error_code_both=0 and
(
($response_error_code=0 or
($response_error_code=1
and
(
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
and
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
)
)
)
)
)
)
and
($include_complete_result_error_severity_both=1 or
($include_complete_result_error_severity_both=0 and
(
($response_error_severity=0 or
($response_error_severity=1
and
(
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
and
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
)
)
)
)
)
)
) (: end all non complete conditions in DtsResult :)
)) then
return
<DtsResult>
{for $xx in $y/LogicalLink
return $xx
}
{for $xx in $y/ComPrimitive
return $xx
}
{for $xx in $y/Type
return $xx
}
{for $xx in $y/State
return $xx
}
{for $xx in $y/StateInfo
return $xx
}

{for $vv in $y/DtsRequest
where
(
(: start complete conditions in DtsRequest :)

($include_complete_result_pdu_request=1 and
( ($request_pdu=1)
and
(
some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_request))
)
)
)
)

or
($include_complete_result_parameter_name_request=1 and
( ($request_pdu=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_request))
)
)
)
)

or
($include_complete_result_parameter_value_request= 1 and
( ($request_parameter_value=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Value, string($parameter_value_request))
)
)
)
)

or
($include_complete_result_parameter_type_request=1 and
( ($request_parameter_type=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Type, string($parameter_type_request))
)
)
)
)

or
($include_complete_result_error_code_request=1 and
( ($request_error_code=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/CodeDescription, string($error_code_request))
)
)
)
)
or
($include_complete_result_error_severity_request=1 and
( ($request_error_severity=1)
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/Severity, string($error_severity_request))
)
)
)
)
or
($include_complete_result_pdu_response=1 and
( ($response_pdu=1)
and
(
some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_response))
)
)
)
)

or
($include_complete_result_parameter_name_response= 1 and
( ($response_pdu=1)
and
(
some $xx in $y/DtsResponse/DtsReponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_response))
)
)
)
)

or
($include_complete_result_parameter_value_response =1 and
( ($response_parameter_value=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_response))
)
)
)
)

or
($include_complete_result_parameter_type_response= 1 and
( ($response_parameter_type=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_response))
)
)
)
)

or
($include_complete_result_error_code_response=1 and
( ($response_error_code=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_response))
)
)
)
)
or
($include_complete_result_error_severity_response= 1 and
( ($response_error_severity=1)
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_response))
)
)
)
)
or
($include_complete_result_pdu_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
and
(some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
)
)
)
or
($include_complete_result_parameter_name_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
)
)
)
or
($include_complete_result_parameter_value_both=1 and
( ($both_parameter_value=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
)
)
)
or
($include_complete_result_parameter_type_both=1 and
( ($both_parameter_type=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
)
)
)

or
($include_complete_result_error_code_both=1 and
( ($both_error_code=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
)
)
)
or
($include_complete_result_error_severity_both=1 and
( ($both_error_severity=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
)
)
)
)(: end complete conditions in DtsRequest :)
or
(
(: start all non complete conditions in DtsRequest :)

($request_pdu=1 or $request_parameter_name=1 or
$request_parameter_type=1 or
$request_parameter_value=1 or $request_error_code=1 or
$request_error_severity=1
or
$both_pdu=1 or $both_parameter_name=1 or $both_parameter_type=1 or
$both_parameter_value=1 or $both_error_code=1 or
$both_error_severity=1
)
and
($include_complete_result_pdu_request=1 or
($include_complete_result_pdu_request=0 and
(
($request_pdu=0 or
($request_pdu=1
and
(
contains($vv/PDU, string($pdu_byte_pattern_request))
)
)
)
)
)
)
and
($include_complete_result_parameter_name_request=1 or
($include_complete_result_parameter_name_request=0 and
(
($request_parameter_name=0 or
($request_parameter_name=1
and
(
some $xx in $vv/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_request))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_request= 1 or
($include_complete_result_parameter_value_request= 0 and
(
($request_parameter_value=0 or
($request_parameter_value=1
and
(
some $xx in $y/DtsRequestParameter/DtsValue satisfies
(
contains($xx/Value, string($parameter_value_request))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_type_request=1 or
($include_complete_result_parameter_type_request=0 and
(
($request_parameter_type=0 or
($request_parameter_type=1
and
(
some $xx in $vv/DtsRequestParameter/DtsValue satisfies
(
contains($xx/Type, string($parameter_type_request))
)
)
)
)
)
)
)
and
($include_complete_result_error_code_request=1 or
($include_complete_result_error_code_request=0 and
(
($request_error_code=0 or
($request_error_code=1
and
(
some $xx in $vv/DtsRequestParameter/DtsError satisfies
(
contains($xx/CodeDescription, string($error_code_request))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_request=1 or
($include_complete_result_error_severity_request=0 and
(
($request_error_severity=0 or
($request_error_severity=1
and
(
some $xx in $vv/DtsRequestParameter/DtsError satisfies
(
contains($xx/Severity, string($error_severity_request))
)
)
)
)
)
)
)
and
($include_complete_result_pdu_both=1 or
($include_complete_result_pdu_both=0 and
(
($request_pdu=0 or
($request_pdu=1
and
(
contains($vv/PDU, string($pdu_byte_pattern_both))
)
)
)
)
)
)
and
($include_complete_result_parameter_name_both=1 or
($include_complete_result_parameter_name_both=0 and
(
($request_parameter_name=0 or
($request_parameter_name=1
and
(
some $xx in $vv/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_both=1 or
($include_complete_result_parameter_value_both=0 and
(
($request_parameter_value=0 or
($request_parameter_value=1
and
(
some $xx in $y/DtsRequestParameter/DtsValue satisfies
(
contains($xx/Value, string($parameter_value_both))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_type_both=1 or
($include_complete_result_parameter_type_both=0 and
(
($request_parameter_type=0 or
($request_parameter_type=1
and
(
some $xx in $vv/DtsRequestParameter/DtsValue satisfies
(
contains($xx/Type, string($parameter_type_both))
)
)
)
)
)
)
)
and
($include_complete_result_error_code_both=1 or
($include_complete_result_error_code_both=0 and
(
($request_error_code=0 or
($request_error_code=1
and
(
some $xx in $vv/DtsRequestParameter/DtsError satisfies
(
contains($xx/CodeDescription, string($error_code_both))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_both=1 or
($include_complete_result_error_severity_both=0 and
(
($request_error_severity=0 or
($request_error_severity=1
and
(
some $xx in $vv/DtsRequestParameter/DtsError satisfies
(
contains($xx/Severity, string($error_severity_both))
)
)
)
)
)
)
)
) (: end all non complete conditions in DtsRequest :)
return $vv
}

{for $vv in $y/DtsResponse
where
(
(: start complete conditions in DtsResponse :)

($include_complete_result_pdu_request=1 and
( ($request_pdu=1
and
(
some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_request))
)
)
)
)
)
or
($include_complete_result_parameter_name_request=1 and
( ($request_pdu=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_request))
)
)
)
)
)
or
($include_complete_result_parameter_value_request= 1 and
( ($request_parameter_value=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Value, string($parameter_value_request))
)
)
)
)
)
or
($include_complete_result_parameter_type_request=1 and
( ($request_parameter_type=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue satisfies

(
contains($xx/Type, string($parameter_type_request))
)
)
)
)
)
or
($include_complete_result_error_code_request=1 and
( ($request_error_code=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/CodeDescription, string($error_code_request))
)
)
)
)
)
or
($include_complete_result_error_severity_request=1 and
( ($request_error_severity=1
and
(
some $xx in $y/DtsRequest/DtsRequestParameter/DtsError satisfies

(
contains($xx/Severity, string($error_severity_request))
)
)
)
)
)
or
($include_complete_result_pdu_response=1 and
( ($response_pdu=1
and
(
some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_response))
)
)
)
)
)
or
($include_complete_result_parameter_name_response= 1 and
( ($response_pdu=1
and
(
some $xx in $y/DtsResponse/DtsReponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_response))
)
)
)
)
)
or
($include_complete_result_parameter_value_response =1 and
( ($response_parameter_value=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_response))
)
)
)
)
)
or
($include_complete_result_parameter_type_response= 1 and
( ($response_parameter_type=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_response))
)
)
)
)
)
or
($include_complete_result_error_code_response=1 and
( ($response_error_code=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_response))
)
)
)
)
)
or
($include_complete_result_error_severity_response= 1 and
( ($response_error_severity=1
and
(
some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_response))
)
)
)
)
)
or
($include_complete_result_pdu_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
and
(some $xx in $y/DtsResponse satisfies
(
contains($xx/PDU, string($pdu_byte_pattern_both))
))
)
)
)
or
($include_complete_result_parameter_name_both=1 and
( ($both_pdu=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
))
)
)
)
or
($include_complete_result_parameter_value_both=1 and
( ($both_parameter_value=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Value, string($parameter_value_both))
))
)
)
)
or
($include_complete_result_parameter_type_both=1 and
( ($both_parameter_type=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsValue
satisfies
(
contains($xx/Type, string($parameter_type_both))
))
)
)
)

or
($include_complete_result_error_code_both=1 and
( ($both_error_code=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/CodeDescription, string($error_code_both))
))
)
)
)
or
($include_complete_result_error_severity_both=1 and
( ($both_error_severity=1)
and
(
(some $xx in $y/DtsRequest/DtsRequestParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
and
(some $xx in $y/DtsResponse/DtsResponseParameter/DtsError
satisfies
(
contains($xx/Severity, string($error_severity_both))
))
)
)
)
)(: end complete conditions in DtsResponse :)
or
(
(: start all non complete conditions in DtsResult :)
(
$response_pdu=1 or $response_parameter_name=1 or
$response_parameter_type=1 or
$response_parameter_value=1 or $response_error_code=1 or
$response_error_severity=1
or
$both_pdu=1 or $both_parameter_name=1 or $both_parameter_type=1 or
$both_parameter_value=1 or $both_error_code=1 or
$both_error_severity=1)

and
($include_complete_result_pdu_response=1 or
($include_complete_result_pdu_response=0 and
(
($response_pdu=0 or
($response_pdu=1
and
(
contains($vv/PDU, string($pdu_byte_pattern_response))

)
)
)
)
)
)
and

($include_complete_result_parameter_name_response= 1 or
($include_complete_result_parameter_name_response= 0 and
(
($response_parameter_name=0 or
($response_parameter_name=1
and
(
some $xx in $vv/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_response))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_response =1 or
($include_complete_result_parameter_value_response =0 and
(
($response_parameter_value=0 or
($response_parameter_value=1
and
(
some $xx in $y/DtsResponseParameter/DtsValue satisfies
(
contains($xx/Value, string($parameter_value_response))
)
)
)
)
)
)
)

and
($include_complete_result_parameter_type_response= 1 or
($include_complete_result_parameter_type_response= 0 and
(
($response_parameter_type=0 or
($response_parameter_type=1
and
(
some $xx in $vv/DtsResponseParameter/DtsValue satisfies
(
contains($xx/Type, string($parameter_type_response))
)
)
)
)
)
)
)

and
($include_complete_result_error_code_response=1 or
($include_complete_result_error_code_response=0 and
(
($response_error_code=0 or
($response_error_code=1
and
(
some $xx in $vv/DtsResponseParameter/DtsError satisfies
(
contains($xx/CodeDescription, string($error_code_response))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_response= 1 or
($include_complete_result_error_severity_response= 0 and
(
($response_error_severity=0 or
($response_error_severity=1
and
(
some $xx in $vv/DtsResponseParameter/DtsError satisfies
(
contains($xx/Severity, string($error_severity_response))
)
)
)
)
)
)
)
and
($include_complete_result_pdu_both=1 or
($include_complete_result_pdu_both=0 and
(
($response_pdu=0 or
($response_pdu=1
and
(
contains($vv/PDU, string($pdu_byte_pattern_both))
)
)
)
)
)
)
and

($include_complete_result_parameter_name_both=1 or
($include_complete_result_parameter_name_both=0 and
(
($response_parameter_name=0 or
($response_parameter_name=1
and
(
some $xx in $vv/DtsResponseParameter satisfies
(
contains($xx/ShortName, string($parameter_name_both))
)
)
)
)
)
)
)
and
($include_complete_result_parameter_value_both=1 or
($include_complete_result_parameter_value_both=0 and
(
($response_parameter_value=0 or
($response_parameter_value=1
and
(
some $xx in $y/DtsResponseParameter/DtsValue satisfies
(
contains($xx/Value, string($parameter_value_both))
)
)
)
)
)
)
)

and
($include_complete_result_parameter_type_both=1 or
($include_complete_result_parameter_type_both=0 and
(
($response_parameter_type=0 or
($response_parameter_type=1
and
(
some $xx in $vv/DtsResponseParameter/DtsValue satisfies
(
contains($xx/Type, string($parameter_type_both))
)
)
)
)
)
)
)

and
($include_complete_result_error_code_both=1 or
($include_complete_result_error_code_both=0 and
(
($response_error_code=0 or
($response_error_code=1
and
(
some $xx in $vv/DtsResponseParameter/DtsError satisfies
(
contains($xx/CodeDescription, string($error_code_both))
)
)
)
)
)
)
)
and
($include_complete_result_error_severity_both=1 or
($include_complete_result_error_severity_both=0 and
(
($response_error_severity=0 or
($response_error_severity=1
and
(
some $xx in $vv/DtsResponseParameter/DtsError satisfies
(
contains($xx/Severity, string($error_severity_both))
)
)
)
)
)
)
)
) (: end all non complete conditions in DtsResponse :)
return $vv
}
</DtsResult>
else ()
}
case element (CloseComPrimitive)
return
{
if(
($exclude_items=0 and
($after_comprimitive_logicallink_name=1 or $after_comprimitive_name=1
or
$after_comprimitive_id=1) and

(
( $after_comprimitive_logicallink_name=0 or
($ after_comprimitive_logicallink_name=1 and
(
some $z in $y/LogicalLink satisfies
(
contains($z/ShortName, string($logical_link_name))
)
)
)
)
and
( $after_comprimitive_name=0 or
( $after_comprimitive_name=1 and
(
contains($y/ShortName, string($comprimitive_name))
)
)
)
and
($ after_comprimitive_id=0 or
($ after_comprimitive_id=1 and
(
contains($y/ID, string($comprimitive_id))
)
)
)
)
)) then
return $y
else ()
}

case element(StopTrace)
{
if( $after_startstoptrace=1 and $exclude_items=0) then
return $y
else ()
}

default return $y
}

</Trace> </ProcessValueTrace>

Dec 12 '05 #7
Hi,

Actually I got the syntax fixed. The typeswitch shouldn't have been
inside { }.

My last issue is: typeswitch ($y) ... case element(a):
.................. $y/CertainChild - is not recognized. Now how is
XQuery supposed to know what type is $y.. How do you do
a cast?

Paul

Dec 14 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Felix Naumann | last post by:
Hi, I am looking for a Java API to represent/generate XQueries. I would imagine it has a class XQuery.java and other classes such as FLWR.java, ORDER.java etc. and one should be able to add...
1
by: inquirydog | last post by:
Can anyone explain to me why the following XQuery expression (a simple xpath expression) returns a different result than the same expression in xslt? document("document.xml")//a/@b For the...
7
by: Jeff Kish | last post by:
Greetings. I can't invest a large amount of time into this, but it would be very helpful if I could do this. I have a directory full of xml files I'd like to be able to query to find out...
11
by: Jeff Kish | last post by:
Just wondering if it was possible to xquery an xml file to retrieve all elements that had a given text value or all elements where any attribute had a value of interest. I guess I could figure...
0
by: Tony Lavinio | last post by:
Dear Stylus Studio Friends, The new year is scarcely one month old, but we already have lots to report! For starters, there's Stylus Studio 6 Release 2. The latest release of Stylus Studio...
1
by: FBS | last post by:
Hi everybody, I wonder if somebody could help me with this issue. I would like to rum some XQuery codes aginst my XML files and since I'm quite new in this area I'm not sure what to do. It is...
1
by: Philipp Schumann | last post by:
Hi .NET XML fans, does anyone know ad hoc whether support for the above standards is planned for .NET 2.0? I suppose this would be extremely valuable for many folks... Thanks, Phil
3
by: Bloody Viking | last post by:
Namaste, Y'all! I've got a valid XQuery expression that I need to convert to XPath 2.0. This expression will be stored in a resource file and applied to XML by a Java program with saxon8.jar...
0
by: jeoffh | last post by:
Background: I am trying to "merge" some attributes into an existing XML column in my MS SQL 2005 database. The general idea is that I have an XML column in a table and I would like to update/delete...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.