473,805 Members | 2,074 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_a nd_trans_to_tab _delim.xsl:
-----------------------------------------
<?xml version="1.0" encoding="UTF-8"?>
<xsl:styleshe et 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="documen t('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.11 1111</latitude>
<date_time>20 03/12/10.16:08</date_time>
</record>
<record>
<longitude>-105.222222</longitude>
<latitude>39.22 2222</latitude>
<date_time>20 03/12/10.16:18</date_time>
</record>
<record>
<longitude>-105.111111</longitude>
<latitude>39.11 1111</latitude>
<date_time>20 03/12/10.16:28</date_time>
</record>
<record>
<longitude>-105.111111</longitude>
<latitude>39.11 1111</latitude>
<date_time>20 03/12/10.17:08</date_time>
</record>
<record>
<longitude>-105.222222</longitude>
<latitude>39.22 2222</latitude>
<date_time>20 03/12/10.17:18</date_time>
</record>
<record>
<longitude>-105.111111</longitude>
<latitude>39.11 1111</latitude>
<date_time>20 03/12/10.17:28</date_time>
</record>
</root>

lrv_trans.xml:
--------------
<?xml version="1.0"?>
<root>
<header>
<driver_id>driv er_id_from_tran s</driver_id>
<vehicle_id>veh icle_id_from_tr ans</vehicle_id>
<duty_shift_id> duty_shift_id_f rom_trans</duty_shift_id>
<route_id>route _id_from_trans</route_id>
<cid_terminal_i d>cid_terminal_ id_from_trans</cid_terminal_id >
</header>
<record>
<date_time>20 03/12/10.16:08</date_time>
<tag_id>tag_id_ from_trans_1</tag_id>
<stop_location_ id>stop_locatio n_id_from_trans _1</stop_location_i d>
<fare_type_cd>f are_type_cd_fro m_trans_1</fare_type_cd>
<blacklist_cd>b lacklist_cd_fro m_trans_1</blacklist_cd>
</record>
<record>
<date_time>20 03/12/10.16:18</date_time>
<tag_id>tag_id_ from_trans_4</tag_id>
<stop_location_ id>stop_locatio n_id_from_trans _4</stop_location_i d>
<fare_type_cd>f are_type_cd_fro m_trans_4</fare_type_cd>
<blacklist_cd>b lacklist_cd_fro m_trans_4</blacklist_cd>
</record>
<header>
<driver_id>driv er_id_from_tran s</driver_id>
<vehicle_id>veh icle_id_from_tr ans</vehicle_id>
<duty_shift_id> duty_shift_id_f rom_trans</duty_shift_id>
<route_id>route _id_from_trans</route_id>
<cid_terminal_i d>cid_terminal_ id_from_trans</cid_terminal_id >
</header>
<record>
<date_time>20 03/12/10.17:08</date_time>
<tag_id>tag_id_ from_trans_1</tag_id>
<stop_location_ id>stop_locatio n_id_from_trans _1</stop_location_i d>
<fare_type_cd>f are_type_cd_fro m_trans_1</fare_type_cd>
<blacklist_cd>b lacklist_cd_fro m_trans_1</blacklist_cd>
</record>
<record>
<date_time>20 03/12/10.17:18</date_time>
<tag_id>tag_id_ from_trans_4</tag_id>
<stop_location_ id>stop_locatio n_id_from_trans _4</stop_location_i d>
<fare_type_cd>f are_type_cd_fro m_trans_4</fare_type_cd>
<blacklist_cd>b lacklist_cd_fro m_trans_4</blacklist_cd>
</record>
</root>
TIA
Jul 20 '05 #1
0 2075

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

Similar topics

1
10354
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 data, but the sample.dat file has duplicate information. I would like to be able to eliminate this, since I have know ability to manipulate the sample.dat. ${ORACLE_HOME}/bin/sqlldr $USERPW /home/sample/sample.ctl ############# sample.ctl...
8
1704
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 know I'll speed up my application loading time by more than 10 seconds (out of about 20). I've run across three situations in which I'm stuck at: Issue One: If my largest Column has (say) 200 lines, other columns will have less data
0
1427
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 certain fields I do not need, some are blank. A typical line would be: Raw data: " ", "30142", "GA", "01001"," ", "MA","
3
5091
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 file is meant to be downloaded to MS Excel on the users' computers. Several such files will be downloaded and appended into the Excel file. Problem: The text file looks good when viewed offline by any text reader, but Excel will not import it...
3
2889
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 that have multi-line addresses and some that don't. So, say my report layout looks like this: Name Address1 Address2
2
1936
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 table looks like this ClaimNum LineNum abcde1234561 abcde1234561
1
1810
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 Heading2
4
1529
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 , Joe
2
7632
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 extracting the data from the XML file into a Dataset and using the method Dataset.ReadXml() we are trying to parse the nodes in the file. But on debugging the following exception arises--- Unexpected XML declaration. The XML declaration must be the...
0
10613
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10363
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10368
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10107
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7649
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5544
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5678
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3846
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3008
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.