xquery help please

Discussion in 'XML' started by paul.rusu@gmail.com, Nov 8, 2005.

  1. Guest

    In the xquery code bellow, i can't seem to get the syntax arranged
    starting with this line if (empty($bb)) then . The problem is either
    syntax error or i have xquery code shown in the output xml. I would
    appreciate help with the syntax of those last lines - how to place the
    curly brackets.


    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
    return
    <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

    :) than i output the close tag - in case i had something before it:)
    if (empty($bb)) then
    ""
    else
    </DtsResult>

    </Trace>

    I tried to place each of the 3 outputs in {..} but i kept getting
    error. I played a little with the {} but i didn't get them and the
    output right. I appreciate your help.

    Best regards.
    Paul
     
    , Nov 8, 2005
    #1
    1. Advertising

  2. 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 ***
     
    Priscilla Walmsley, Nov 8, 2005
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jeff Kish

    xquery help

    Jeff Kish, Oct 14, 2004, in forum: XML
    Replies:
    7
    Views:
    531
    Jeff Kish
    Oct 18, 2004
  2. Tony Lavinio
    Replies:
    0
    Views:
    412
    Tony Lavinio
    Apr 28, 2005
  3. xquery help

    , Nov 7, 2005, in forum: XML
    Replies:
    0
    Views:
    455
  4. KK
    Replies:
    2
    Views:
    601
    Big Brian
    Oct 14, 2003
  5. CK
    Replies:
    1
    Views:
    464
Loading...

Share This Page