[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

RE: Getting file-name of input-file.xml at runtime

Subject: RE: Getting file-name of input-file.xml at runtime
From: "Steve Gold" <Steve@xxxxxxxxxxxxx>
Date: Mon, 9 Dec 2002 21:38:17 -0500
xsl input file name
There is a way to accomplish this, in sort of a different way.  Instead
of having one XML file with a hard-coded XSL in it, use what I call a
control file with the file names in it.  So you will have a control
file, your XML document and an XSL sheet.  The control document looks
like this:

<?xml version="1.0" encoding='ISO-8859-1'?>
<?xml-stylesheet type="text/xsl" href="Table_of_Contents.xsl"?>
<PAGE>
<ROWSET>
<ROW ID="1">
	<TITLE>Steve's stuff</TITLE>
	<FILE_NAME>file1.xml</FILE_NAME>
</ROW>
</ROWSET>
<ROWSET>
<ROW ID="2">
	<FILE_NAME>file2.xml</FILE_NAME>
</ROW>
</ROWSET>
</PAGE>

As you can see, I have two input files, but you can use just one if you
want.  The xsl sheet this file calls, reads the file names from this XML
file and the uses the document() command to open file1.xml, then
file2.xml etc.

Here are snips from the xsl.  

First it loops through the file names:
			<xsl:for-each select="PAGE/ROWSET/ROW">
				<xsl:call-template name="file_loop">
				</xsl:call-template>
			</xsl:for-each>

Then it loops through the actual XML files:
<xsl:template name="file_loop">
	<xsl:variable name="file_name"><xsl:value-of select="FILE_NAME"
/></xsl:variable>
	<xsl:for-each select="document($file_name)/ROWSET/ROW">
		    <tr>
		    <td><xsl:value-of select="SECTION"/></td>
		    </tr>
	</xsl:for-each>
</xsl:template>

You could print out the file name at any time.  Hope this helps.


-----Original Message-----
From: owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx
[mailto:owner-xsl-list@xxxxxxxxxxxxxxxxxxxxxx] On Behalf Of Mike Brown
Sent: Monday, December 09, 2002 8:25 PM
To: xsl-list@xxxxxxxxxxxxxxxxxxxxxx
Subject: Re:  Getting file-name of input-file.xml at runtime


Jan Mendling wrote:
> Can I somehow use the document function to retrieve at
> runtime the file-name of the inputfile where my stylesheet
> is currently working on?

No.

The standard answer to this FAQ is to provide the filename
as a top-level parameter.


Mike

-- 
  Mike J. Brown   |  http://skew.org/~mike/resume/
  Denver, CO, USA |  http://skew.org/xml/

 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

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.