Subject: RE: [xsl] Getting file-name of input-file.xml at runtime From: "Steve Gold" <Steve@xxxxxxxxxxxxx> Date: Mon, 9 Dec 2002 21:38:17 -0500 |
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: [xsl] 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 |
---|
|
<- Previous | Index | Next -> |
---|---|---|
Re: [xsl] Getting file-name of inpu, Mike Brown | Thread | [xsl] Why is apply-templates not ca, Jeff Lowery |
RE: [xsl] how to find position - pl, Rakesh Seth | Date | [xsl] Identifying output from the (, Hugh Dixon |
Month |