L
Luke Airig
I have an xsl stylesheet that merges data from two files based upon a
common date/time field. Right now, one of the file names is
hard-coded in the xsl file. Is there any way to make this parameter
driven so I can genericize it to process different file names in
different directories?
Here is my current run syntax:
java com.icl.saxon.StyleSheet -o
C:\bin\merged_lrv_gps_and_trans_tab_delim.xml C:\bin\lrv_trans.xml
C:\bin\merge_lrv_gps_and_trans_to_tab_delim.xsl
And here is the xsl:
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">
<xslutput method="text"/>
<xsl:variable name="delim" select="' '"/> <!-- tab -->
<xsl:variable name="nl" select="'
'"/> <!-- 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">
<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>
TIA
common date/time field. Right now, one of the file names is
hard-coded in the xsl file. Is there any way to make this parameter
driven so I can genericize it to process different file names in
different directories?
Here is my current run syntax:
java com.icl.saxon.StyleSheet -o
C:\bin\merged_lrv_gps_and_trans_tab_delim.xml C:\bin\lrv_trans.xml
C:\bin\merge_lrv_gps_and_trans_to_tab_delim.xsl
And here is the xsl:
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">
<xslutput method="text"/>
<xsl:variable name="delim" select="' '"/> <!-- tab -->
<xsl:variable name="nl" select="'
'"/> <!-- 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">
<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>
TIA