IBM webMethods Hybrid Integration

IBM webMethods Hybrid Integration

Join this online group to communicate across IBM product users and experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only
Expand all | Collapse all

syntax error using XQuery delete

  • 1.  syntax error using XQuery delete

    Posted Thu November 18, 2004 08:36 PM

    This works:

    declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
    let $doc := (
    for $z in (
    for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
    and $q/km_properties/document_type/details/detail=‘PCN’
    return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
    ) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
    return $z)
    for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
    return $a



    But this similar query produces a syntax error:

    declare namespace tf = “http://namespaces.softwareag.com/tamino/TaminoFunction
    declare namespace xs = “XML Schema
    declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators
    let $doc := (
    for $z in (
    for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
    and $q/km_properties/document_type/details/detail=‘PCN’
    return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
    ) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
    return $z)
    update for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
    do delete $a/…


    The only difference occurs in the last two lines. I want to delete these documents, which I can see using the first query. I believe $a returns me the root node, and for delete I need to go up one, thus the /…

    (I am looking at Trevor Ford’s reply to
    Delete XML Instance with XQuery, posted by Michelle in the Tamino API for Java forum.)

    Thanks

    Neil Keefe


    #API-Management
    #Tamino
    #webMethods


  • 2.  RE: syntax error using XQuery delete

    Posted Fri November 19, 2004 04:23 PM

    Hi,

    In order to get a valid update statement you just have to move the ?update? key word. The resulting update statement looks like this:

    declare namespace tf = “http://namespaces.softwareag.com/tamino/TaminoFunction
    declare namespace xs = “XML Schema
    declare namespace xf = “W3C XQuery 1.0 and XPath 2.0 Functions and Operators

    update
    let $doc := (
    for $z in (
    for $q in input()/ucr where $q/km_properties/original_system=‘PSD’ and $q/@phase!=1001
    and $q/km_properties/document_type/details/detail=‘PCN’
    return {tf:getDocname(root($q))}{$q/km_properties/original_docid}
    ) where not(tf:containsText( $z/dn , string-join(( ‘‘, $z/original_docid,’’), “”)))
    return $z)
    for $a in input()/ucr where $doc/dn = tf:getDocname(root($a))
    do delete $a/…


    Best regards,

    Thorsten Fiebig


    #API-Management
    #Tamino
    #webMethods