This week's giveaway is in the EJB and other Java EE Technologies forum.
We're giving away four copies of EJB 3 in Action and have Debu Panda, Reza Rahman, Ryan Cuprak, and Michael Remijan on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XSL Global Parameter Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL Global Parameter" Watch "XSL Global Parameter" New topic
Author

XSL Global Parameter

Hari Shankar Gentyala
Greenhorn

Joined: Sep 23, 2003
Posts: 17
Hi,
I want to pass a runtime parameter to an XSL file through my java code.This parameter value should be set to a global parameter in my XSL file.My XSL should work accordingly depending on this parameter.

Can some one help me to make this XSL file take the global parameter value.

Thanks in advance,
Hari


G.H.S.Prasad
Balaji Loganathan
author and deputy
Bartender

Joined: Jul 13, 2001
Posts: 3150
if you are suing xalan for java then
you can do it like this..
String globalVal = "foo";
Transformer transformer=TransformerFactory.newInstance().newTransformer(xslSource);
transformer.setParameter("globalVal", globalVal);
see here for more info http://xml.apache.org/xalan-j/samples.html#usestylesheetparamservlet


Spritle Software Blogs
Lasse Koskela
author
Sheriff

Joined: Jan 23, 2002
Posts: 11962
    
    5
You could put a placeholder (e.g. "@variablename@") into your XSL file and run it through a filter which replaces all @...@ with the corresponding runtime value. You could start by looking into extending javax.xml.transform.stream.StreamSource or java.io.InputStream. Although Xalan's setParameter() is definitely a better alternative if you can trust on using Xalan instead of "some" XSL engine.
[ November 06, 2003: Message edited by: Lasse Koskela ]

Author of Test Driven (2007) and Effective Unit Testing (2013) [Blog] [HowToAskQuestionsOnJavaRanch]
 
wood burning stoves
 
subject: XSL Global Parameter
 
Similar Threads
charSet parameter set using java XSL API
How to read some parsed value from my target xml file in XSLT
Passing javascript value to XSL
xsl variables to core set
single quote double quotes problem ,,ASAP