473,385 Members | 1,752 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,385 software developers and data experts.

Tweak xsl to eliminate duplicate data and blank lines

I am trying to merge two xml files based on common date/time and then
write out a tab-delimited xml file with the header record from one of
the input files concatenated in front of the merged detail records in
the output file. The version I have is close to what I need except it
concatenates two sets of header records in front of each merged detail
record and the first two lines in the file and the last line is blank.

Can someone please tell me how to tweak the xsl stylesheet to get rid
of the duplicate concatenated header fields and the blank lines?

Here are the xsl and xml files:

merge_lrv_gps_and_trans_to_tab_delim.xsl:
-----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="text"/>
<xsl:variable name="delim" select="'&#x9;'"/> <!-- tab -->
<xsl:variable name="nl" select="'&#xA;'"/> <!-- newline -->
<xsl:variable name="head">
<xsl:for-each select="/root/header/*">
<xsl:value-of select="concat(., $delim)"/>
</xsl:for-each>
</xsl:variable>

<xsl:template match="/root/record">
<!--note: if lrv_gps.xml is in a different directory, you will
need to use the relative path or URL-->
<xsl:variable name="gps"
select="document('lrv_gps.xml')/root/record[date_time =
current()/date_time]"/>
<xsl:value-of select="$head"/>
<xsl:value-of select="concat($gps/longitude, $delim,
$gps/latitude, $delim)"/>
<xsl:for-each select="*">
<xsl:value-of select="concat(., $delim)"/>
</xsl:for-each>
</xsl:template>

<!--this empty template is to stop the header values from printing at
top of page-->
<xsl:template match="header">
</xsl:template>

</xsl:stylesheet>
lrv_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>
<record>
<longitude>-105.111111</longitude>
<latitude>39.111111</latitude>
<date_time>2003/12/10.17:08</date_time>
</record>
<record>
<longitude>-105.222222</longitude>
<latitude>39.222222</latitude>
<date_time>2003/12/10.17:18</date_time>
</record>
<record>
<longitude>-105.111111</longitude>
<latitude>39.111111</latitude>
<date_time>2003/12/10.17:28</date_time>
</record>
</root>

lrv_trans.xml:
--------------
<?xml version="1.0"?>
<root>
<header>
<driver_id>driver_id_from_trans</driver_id>
<vehicle_id>vehicle_id_from_trans</vehicle_id>
<duty_shift_id>duty_shift_id_from_trans</duty_shift_id>
<route_id>route_id_from_trans</route_id>
<cid_terminal_id>cid_terminal_id_from_trans</cid_terminal_id>
</header>
<record>
<date_time>2003/12/10.16:08</date_time>
<tag_id>tag_id_from_trans_1</tag_id>
<stop_location_id>stop_location_id_from_trans_1</stop_location_id>
<fare_type_cd>fare_type_cd_from_trans_1</fare_type_cd>
<blacklist_cd>blacklist_cd_from_trans_1</blacklist_cd>
</record>
<record>
<date_time>2003/12/10.16:18</date_time>
<tag_id>tag_id_from_trans_4</tag_id>
<stop_location_id>stop_location_id_from_trans_4</stop_location_id>
<fare_type_cd>fare_type_cd_from_trans_4</fare_type_cd>
<blacklist_cd>blacklist_cd_from_trans_4</blacklist_cd>
</record>
<header>
<driver_id>driver_id_from_trans</driver_id>
<vehicle_id>vehicle_id_from_trans</vehicle_id>
<duty_shift_id>duty_shift_id_from_trans</duty_shift_id>
<route_id>route_id_from_trans</route_id>
<cid_terminal_id>cid_terminal_id_from_trans</cid_terminal_id>
</header>
<record>
<date_time>2003/12/10.17:08</date_time>
<tag_id>tag_id_from_trans_1</tag_id>
<stop_location_id>stop_location_id_from_trans_1</stop_location_id>
<fare_type_cd>fare_type_cd_from_trans_1</fare_type_cd>
<blacklist_cd>blacklist_cd_from_trans_1</blacklist_cd>
</record>
<record>
<date_time>2003/12/10.17:18</date_time>
<tag_id>tag_id_from_trans_4</tag_id>
<stop_location_id>stop_location_id_from_trans_4</stop_location_id>
<fare_type_cd>fare_type_cd_from_trans_4</fare_type_cd>
<blacklist_cd>blacklist_cd_from_trans_4</blacklist_cd>
</record>
</root>
TIA
Jul 20 '05 #1
0 2058

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

Similar topics

1
by: gilgantic | last post by:
Is there anyway of eliminating duplicate entries as the database loads data using SQLLDR and/or .ctl (Control File)? I use the following command line using SQLLDR and a control file to load my...
8
by: Mr. B | last post by:
I'm updating my current VB.et application. I currently reads about 6 tables from an MS Data base. I've created a new MDB file which combines the 6 tables into 1 table. I'm doing this because I...
0
by: Roland Hall | last post by:
I'm looking for information on working with large data files using FSO, XML. I have a program which creates a large CSV file, over 7mb. It's a rate table of freight shipping costs. There are...
3
by: Wade G. Pemberton | last post by:
Help!: I use javascript to format repetitive data from a web page input FORM into a long string , and save it as lines of comma delimited data in a text file on a Unix server. The text...
3
by: FZ | last post by:
Hi gang, I was wondering if someone would be kind enough to help me with the following problem. I have created a report that prints shipping labels. The problem is that I have some customers...
2
by: Pablo | last post by:
Hello, there, I have a table tblData which has pharmacy data. The table has following fields: ClaimNum, LineNum... The ClaimNum has claim number which is 12 characters. LineNum is NULL. The...
1
by: satya.mahesh | last post by:
Hi All, I am working on a problem which "eliminates blank lines in export (between headings and when a heading is empty)". I want a macro which will do this job for me. For e.g: Heading1 ...
4
by: sandi | last post by:
hi there i have fields name called .. PAF (text) , PNo (Number ) , LastName (Text) 2006/214/2 , 220101 , Winne 2006/321/3, 521496 , Joe 2006/321/1 , 521496 , Joe 2006/541/4 , 521496 ,...
2
by: Eliza | last post by:
we have written a C# program which generates an XML file from a Client computer and this file is being transfered to the Server side(using Socket programming). at the Server side we are first...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: 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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.