Merge two xml files on common date field and write out tab-delimited file

Discussion in 'XML' started by Luke Airig, Dec 21, 2003.

  1. Luke Airig

    Luke Airig Guest

    I am using the Saxon xml parser and I need some help transforming the
    following 2 xml files:

    gps.xml:
    --------
    <?xml version="1.0"?>
    <root>
    <record>
    <longitude>-105.111111</longitude>
    <latitude>39.111111</latitude>
    <date_time>2003/12/10.16:08</date_time>
    </record>
    <record>
    <longitude>-105.222222</longitude>
    <latitude>39.222222</latitude>
    <date_time>2003/12/10.16:18</date_time>
    </record>
    <record>
    <longitude>-105.111111</longitude>
    <latitude>39.111111</latitude>
    <date_time>2003/12/10.16:28</date_time>
    </record>
    </root>

    trans.xml:
    ----------
    <?xml version="1.0"?>
    <root>
    <header>
    <driver_id>driver_id1</driver_id>
    <vehicle_id>vehicle_id1</vehicle_id>
    <duty_shift_id>duty_shift_id1</duty_shift_id>
    <route_id>route_id1</route_id>
    <cid_terminal_id>cid_terminal_id1</cid_terminal_id>
    </header>
    <record>
    <date_time>2003/12/10.16:08</date_time>
    <tag_id>tag_id1</tag_id>
    <stop_location_id>stop_location_id1</stop_location_id>
    <fare_type_cd>fare_type_cd1</fare_type_cd>
    <blacklist_cd>blacklist_cd1</blacklist_cd>
    </record>
    <record>
    <date_time>2003/12/10.16:18</date_time>
    <tag_id>tag_id2</tag_id>
    <stop_location_id>stop_location_id2</stop_location_id>
    <fare_type_cd>fare_type_cd2</fare_type_cd>
    <blacklist_cd>blacklist_cd2</blacklist_cd>
    </record>
    </root>

    I have a klugey, multiple-step solution right now and I would like a
    single xsl stylesheet to:

    1. Merge the two input file <record>'s on the date_time field.
    2. Pass the <header> through as well and wind up with a
    tab-delimited flat file with the <header> fields appended to the front
    of each group of <record> fields as follows:

    merged_tab_delimited.xml:
    -------------------------
    driver_id1 vehicle_id1 duty_shift_id1 route_id1 cid_terminal_id1
    -105.111111 39.111111 2003/12/10.16:08 tag_id1 stop_location_id1
    fare_type_cd1 blacklist_cd1

    driver_id1 vehicle_id1 duty_shift_id1 route_id1 cid_terminal_id1
    -105.222222 39.222222 2003/12/10.16:18 tag_id2 stop_location_id2
    fare_type_cd2 blacklist_cd2

    I'm a total neophyte with xml and I'm sure there is a
    straight-forward, elegant solution to this.

    TIA
     
    Luke Airig, Dec 21, 2003
    #1
    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. Luke Airig
    Replies:
    1
    Views:
    959
    Patrick TJ McPhee
    Dec 16, 2003
  2. Gibson
    Replies:
    2
    Views:
    1,462
    Gibson
    Nov 19, 2008
  3. Cs Webgrl
    Replies:
    1
    Views:
    236
    James Edward Gray II
    Jul 1, 2010
  4. Replies:
    1
    Views:
    380
    ZedGama3
    Apr 14, 2004
  5. Srikant
    Replies:
    1
    Views:
    540
    Greg Bacon
    Sep 29, 2007
Loading...

Share This Page