This is the mail archive of the
xsl-list@mulberrytech.com
mailing list .
RE: multiple input files to one output file
- To: xsl-list at mulberrytech dot com
- Subject: RE: multiple input files to one output file
- From: James Garriss <jgarriss at mitre dot org>
- Date: Fri, 04 Feb 2000 12:34:30 -0500
- Reply-To: xsl-list at mulberrytech dot com
LotusXSL 0.19.2 has a very elegant solution for passing parameters into an
XSL stylesheet. After instantiating the processor, you call
processor.setStylesheetParam to replace a placeholder with some
value. Here at MITRE, we replaced a placeholder with a URI of an XML file,
thus we were able to access the contents of it directly, just as if it was
a variable. This is done pretty much in the same manner as passing a
parameter to a template.
Note that we are calling LotusXSL from a Java servlet. Here's the function
we used (note that much of this is code right out of the LotusXSL
documentation):
***************
public static void transform(String xmlSourceURL, String xslURL, String
outputURL, String userDirectoryURL, String userName)
throws java.io.IOException, java.net.MalformedURLException,
org.xml.sax.SAXException
{
// Instantiate an XSLTProcessor.
org.apache.xalan.xslt.XSLTProcessor processor =
org.apache.xalan.xslt.XSLTProcessorFactory.getProcessor();
// Set a param named "userdirectory", that the stylesheet can obtain.
processor.setStylesheetParam("userdirectory", "'" + userDirectoryURL + "'");
// Create the 3 objects the XSLTProcessor needs to perform the
transformation.
org.apache.xalan.xslt.XSLTInputSource xmlSource =
new org.apache.xalan.xslt.XSLTInputSource (xmlSourceURL);
org.apache.xalan.xslt.XSLTInputSource xslSheet =
new org.apache.xalan.xslt.XSLTInputSource (xslURL);
org.apache.xalan.xslt.XSLTResultTarget xmlResult =
new org.apache.xalan.xslt.XSLTResultTarget (outputURL);
// Perform the transformation.
processor.process(xmlSource, xslSheet, xmlResult);
}
***************
Our stylesheet has this line in it....
<xsl:param name="userdirectory" select="'default'"/>
and the placeholder "default" is what gets replaced. Pretty nifty, eh?
--J
***************
At 02:54 AM 2/2/2000 , Linda van den Brink wrote:
>I've used the document() function before, but this time I don't know the
>paths and filenames of the documents beforehand. These are thousands of
>files in hundreds of different directories.
>
>I do have XML files that specify the filenames and paths of all the
>documents in a specific subdirectory. Could I somehow read such a
>filenames-file and call the document function for each of the files listed,
>and then extract the information I want from each document?
>
>Maybe my best option is to use a Perl script or something similar...
>
>-----Original Message-----
>From: Steve Tinney [mailto:stinney@sas.upenn.edu]
>Sent: Tuesday, February 01, 2000 3:58 PM
>To: xsl-list@mulberrytech.com
>Subject: Re: multiple input files to one output file
>
>
>Linda van den Brink wrote:
>> Is it possible with XSLT to have lots of input files, and create one
>output
>> file listing specific data from each of the files?
>>
>> What are my options to achieve this?
>
>XSLT spec under document(). You will need to manage the actual
>integration of your list of documents into the XSL script, either
>manually, by use of some kind of XML control file, or with a Java
>extension function.
>
> Steve
>
>--
>----------------------------------------------------------------------
>Steve Tinney Babylonian Section
> * University of Pennsylvania Museum
>stinney@sas.upenn.edu Phila, PA. 215-898-4047
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
>
>
> XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list
James Garriss | The MITRE Corporation | jgarriss @ mitre.org
XSL-List info and archive: http://www.mulberrytech.com/xsl/xsl-list