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

Re: Passing parameter to stylesheet from servlet

Subject: Re: Passing parameter to stylesheet from servlet
From: Ovidiu Predescu <ovidiu@xxxxxxxxxx>
Date: Thu, 09 Nov 2000 10:56:32 -0800
request.getparameter servlet
On Thu, 9 Nov 2000 21:01:58 +0530, "Manjul Sahay" <manjuls@xxxxxxxxxx> wrote:

> hi,
> please help me on this regard !
> 
> How do I pass request parameters to stylesheet from a servlet. ?
> The problem is that the 2nd argument of the method setStylesheetParam("","")
> , takes an expression and string has to be given like "'I am a string '".
> Now how do I pass request parameters in this 2nd argument ?
> 
> The code i am using is faulty and I want to know how to correct it -
> 
> String category_ = request.getParameter("category");
> String topic_ = request.getParameter("topic");
> String course_ = request.getParameter("course");
> String file_ = request.getParameter("file");
> 
> XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
> 
> XSLTInputSource input=new
> XSLTInputSource("file:///c:/jdk/library/insert.xml");
> XSLTInputSource style=new
> XSLTInputSource("file:///c:/jdk/library/insert.xsl");
> XSLTResultTarget output=new XSLTResultTarget("c:/jdk/library/try.xml");
> 
> try{ 
> 
> processor.setStylesheetParam("category",category_); 
> processor.setStylesheetParam("topic","'topic_'"); 
> processor.setStylesheetParam("course","'course_'"); 
> processor.setStylesheetParam("file","'file_'"); 

The values of the arguments should be XObject instances not String instances.
You need to modify the code like this:

XSLTProcessor processor = XSLTProcessorFactory.getProcessor();
XObject category = processor.createXString(request.getParameter("category"));
...
processor.setStylesheetParam("category", category);


Hope this helps,
-- 
Ovidiu Predescu <ovidiu@xxxxxxxxxx>
http://orion.nsr.hp.com/ (inside HP's firewall only)
http://www.geocities.com/SiliconValley/Monitor/7464/



 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.