AW: [xsl] Supplying input file name as parameter

Subject: AW: [xsl] Supplying input file name as parameter
From: "Fries, Markus, fiscus GmbH, Bonn" <M.Fries@xxxxxxxxxxx>
Date: Thu, 23 May 2002 12:55:50 +0200
Hi,

If you need one stylesheet with different inputs but only one at a time, you
do depending on your stylesheet processor s.th. like 

xalan -XSL <stylesheet> -IN <inputfile> -OUT <outputfile>


If you do need more than one input file in a single transformation you have
different
options.  You read from 

<?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform";
                version="1.0">

  <xsl:param name="inputfile"/>
  
  <xsl:output method="text"/>

  <xsl:template match="/">
    <xsl:value-of select="item1"/>
    <xsl:value-of select="document(item1/@name)/item"/>
    <xsl:value-of select="document($inputfile)/item"/>
  </xsl:template>

</xsl:stylesheet>

Now 

xalan -XSL <stylesheet> -IN <inputfile> -OUT <outputfile> -PARAM inputfile
input.xml


[input.xml]
<item1 name="referenced.txt">
Item 1 Text
</item1>

[referenced.txt]
<?xml version="1.0" encoding="utf-8"?>
<item>
Referenced Text
</item>

will result in

[output.xml]
Item 1 Text
Referenced Text
Referenced Text

So you can read from a file with a fixed name the list of inputs. Or you
pass it with the parameters.
What does not work is using document({$inputfile}) as those are attribute
value templates.


Maybe you need some more basic reading?

Cheers

Markus


-----Ursprüngliche Nachricht-----
Von: Mukul.Mudgal@xxxxxxxxxxx [mailto:Mukul.Mudgal@xxxxxxxxxxx]
Gesendet: Donnerstag, 23. Mai 2002 11:23
An: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Betreff: [xsl] Supplying input file name as parameter


Hi all
How can we supply a input (Source)file name as parameter instead of using
document() function in XSL file

I need to make a XSL file so generic so that it could be worked upon a
number of input files.So I need to supply file name as a parameter instead
of using document() function.


thanks
Mukul





 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread