|
[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message] RE: multiple input files to one output file
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@xxxxxxxxxxxxx] >Sent: Tuesday, February 01, 2000 3:58 PM >To: xsl-list@xxxxxxxxxxxxxxxx >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@xxxxxxxxxxxxx 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
|
PURCHASE STYLUS STUDIO ONLINE TODAY!Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced! Download The World's Best XML IDE!Accelerate XML development with our award-winning XML IDE - Download a free trial today! Subscribe in XML format
|

Cart








