Pass file name parameter to xsl stylesheet

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

  1. Luke Airig

    Luke Airig Guest

    I am using the Saxon 6.5.3 engine and I have an xsl stylesheet that
    merges two files on a date_time field and writes out a tab-delimited
    flat file. My working version has a hard-coded file name in the xsl
    file. I dug through the
    Saxon documenation to find a way to feed a file name param to
    eliminate the hard-coded file name in the xsl. This version executes
    but does not appear to do the merge processing and drops the longitude
    and latitude values. Can
    anyone give me some insight as to what I am doing wrong with this?
    My command line run syntax is commented at the bottom.

    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:eek:utput 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="/">
    <xsl:apply-templates select="root/record"/>
    </xsl:template>

    <xsl:template match="record">
    <!--note: if lrv_gps.xml is in a different directory, you will
    need to use the relative path or URL-->
    <!-- select="document('lrv_gps.xml')/root/record[date_time =
    current()/date_time]"/> -->
    <xsl:param name="lrv_gps_file"/>
    <xsl:variable name="gps"
    select="document($lrv_gps_file)/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:value-of select="$nl"/>
    </xsl:template>

    </xsl:stylesheet>

    <!-- 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
    {lrv_gps_file=lrv_gps.xml}
    -->
    Luke Airig, Dec 26, 2003
    #1
    1. Advertising

  2. Luke Airig

    Ed Beroset Guest

    Luke Airig wrote:

    > Saxon documenation to find a way to feed a file name param to
    > eliminate the hard-coded file name in the xsl. This version executes
    > but does not appear to do the merge processing and drops the longitude
    > and latitude values.


    You're very close. The only problem is that the param is not declared
    in the right place. If you move it just after the <xsl:stylesheet> tag,
    I think it should work just fine:

    > 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:eek:utput method="text"/>

    <xsl:param name="lrv_gps_file"/>
    > <xsl:variable name="delim" select="' '"/> <!-- tab -->


    The parameter is being passed to the stylesheet and not to the record
    template as you had written it.

    Ed
    Ed Beroset, Dec 29, 2003
    #2
    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. =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=

    Stylesheet referanse i stylesheet

    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=, Jul 3, 2004, in forum: XML
    Replies:
    3
    Views:
    562
    =?ISO-8859-1?Q?J=F8rn_Tommy_Kinder=E5s?=
    Jul 4, 2004
  2. Steven An
    Replies:
    1
    Views:
    490
    Martin Honnen
    Nov 23, 2004
  3. Thomas Sommer
    Replies:
    0
    Views:
    422
    Thomas Sommer
    Nov 25, 2004
  4. MC
    Replies:
    1
    Views:
    7,235
    David Carlisle
    Mar 24, 2005
  5. Replies:
    0
    Views:
    520
Loading...

Share This Page