Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > eliminate hard-coded file names in xsl

Reply
Thread Tools

eliminate hard-coded file names in xsl

 
 
Luke Airig
Guest
Posts: n/a
 
      12-23-2003
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"
xmlnssl="http://www.w3.org/1999/XSL/Transform">
<xslutput 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">
<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
 
Reply With Quote
 
 
 
 
Dimitre Novatchev
Guest
Posts: n/a
 
      12-24-2003

"Luke Airig" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed) om...
> 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?


Yes, pass the filename as a parameter to the transformation and in your xslt
code use a global xslaram with the same name as that of the externally
passed parameter.

Here's an excerpt from the Saxon 6.5.3 documentation (\doc\using-xsl.html):

"A param takes the form name=value, name being the name of the parameter,
and value the value of the parameter. These parameters are accessible within
the stylesheet as normal variables, using the $name syntax, provided they
are declared using a top-level xslaram element. If there is no such
declaration, the supplied parameter value is silently ignored.
Under Windows it is possible to supply a value containing spaces by
enclosing it in double quotes, for example name="John Smith". This is a
feature of the operating system shell, not something Saxon does, so it may
not work the same way under every operating system."



Dimitre Novatchev.
FXSL developer, XML Insider,

http://fxsl.sourceforge.net/ -- the home of FXSL
Resume: http://fxsl.sf.net/DNovatchev/Resume/Res.html






 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Removing file names with '.' in their names from list? Sfdesigner Sfdesigner Ruby 5 08-13-2007 02:38 AM
XSL Question tp xsl:for-each and xsl:variable schaf@2wire.ch XML 1 05-27-2005 09:25 PM
logical puzzle: how to generate reasonable archive file names fromfile and directory names fBechmann Python 0 06-10-2004 07:13 AM
Tweak xsl to eliminate duplicate data and blank lines Luke Airig XML 0 12-23-2003 10:06 PM
XSL rules applying to XSD (XML schema) defined type names (as opposed to node names) Lewis G. Pringle, Jr. XML 0 09-30-2003 10:34 PM



Advertisments