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.


#TechXchangePresenter
 View Only
  • 1.  help order by

    Posted Wed June 23, 2004 07:27 AM

    I have a xml file ,and I want to sort like this:
    first,order “ADVERT_BAND”
    second,in each “ADVERT_TAPE” order “DAYPLAN_DATE”
    and I want keep the hierarchy( structure)
    the orignial xml file is:
    - <ADVERT_INFO>
    - <ADVERT_INFO_ROW num=“1”>
    <ADVERT_BAND>band_A6</ADVERT_BAND>
    - <ADVERT_TAPE>
    - <ADVERT_TAPE_ROW num=“1”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“2”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“3”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    </ADVERT_TAPE>
    </ADVERT_INFO_ROW>
    - <ADVERT_INFO_ROW num=“2”>
    <ADVERT_BAND>band_A5</ADVERT_BAND>
    - <ADVERT_TAPE>
    - <ADVERT_TAPE_ROW num=“1”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“2”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“3”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    </ADVERT_TAPE>
    </ADVERT_INFO_ROW>
    - <ADVERT_INFO_ROW num=“3”>
    <ADVERT_BAND>band_A1</ADVERT_BAND>
    - <ADVERT_TAPE>
    - <ADVERT_TAPE_ROW num=“1”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“2”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“3”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    </ADVERT_TAPE>
    </ADVERT_INFO_ROW>
    </ADVERT_INFO>

    ------------------
    I want the output file like this:
    - <ADVERT_INFO>
    <ADVERT_INFO_ROW num=“3”>
    <ADVERT_BAND>band_A1</ADVERT_BAND>
    - <ADVERT_TAPE>
    - <ADVERT_TAPE_ROW num=“1”>
    - <ADVERT_DAYPLAN>
    - <ADVERT_DAYPLAN_ROW num=“1”>

    + <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    - <ADVERT_TAPE_ROW num=“2”>
    - <ADVERT_DAYPLAN>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“2”>
    <DAYPLAN_DATE>20040501</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    - <ADVERT_DAYPLAN_ROW num=“3”>
    <DAYPLAN_DATE>20040601</DAYPLAN_DATE>
    </ADVERT_DAYPLAN_ROW>
    <ADVERT_DAYPLAN_ROW num=“1”>
    <DAYPLAN_DATE>20040701</DAYPLAN_DATE>
    </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>


    </ADVERT_INFO>

    how can I do in xquery?
    thanks!


    #webMethods
    #API-Management
    #Tamino


  • 2.  RE: help order by

    Posted Wed June 23, 2004 05:33 PM

    Hi,

    the following query preserves the document but reorders the ADVERT_INFO_ROWs by
    ADVERT_BAND and the ADVERT_DAYPLAN_ROWs by DAYPLAN_DATE:

    let $info_rows :=
    for $info_row in input()/ADVERT_INFO/ADVERT_INFO_ROW
    return (let $tape_rows := $info_row/ADVERT_TAPE/ADVERT_TAPE_ROW
    return <ADVERT_INFO_ROW num = “{ $info_row/@num }”>
    { $info_row/ADVERT_BAND }
    <ADVERT_TAPE> {
    for $tape_row in $tape_rows
    let $dayplan_rows := $tape_row/ADVERT_DAYPLAN/ADVERT_DAYPLAN_ROW
    return <ADVERT_TAPE_ROW num = “{ $tape_row/@num }”>
    <ADVERT_DAYPLAN> {
    $dayplan_rows sort by (DAYPLAN_DATE)
    } </ADVERT_DAYPLAN>
    </ADVERT_TAPE_ROW>
    } </ADVERT_TAPE>
    </ADVERT_INFO_ROW>)
    sort by (ADVERT_BAND)
    return <ADVERT_INFO> { $info_rows } </ADVERT_INFO>

    Regards,
    Juliane.


    #API-Management
    #Tamino
    #webMethods


  • 3.  RE: help order by

    Posted Thu June 24, 2004 04:21 AM

    Hi Juliane
    Thanks for your quick response.I think it can work well.And i implement this function the same way yestady.I think it is a little complex.And I should keep the structure manually.It is a nested query.And I think it will be more convience By adding deep sort and keep hierarchy fuction,just like this:for $some in input()//somerow order by $some//“the element you want to sort” deep keepHierarchy.I hope the w3c can add this fuction .Thank you very much again!


    #API-Management
    #webMethods
    #Tamino