File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSL Global Parameter" Watch "XSL Global Parameter" New topic

XSL Global Parameter

Hari Shankar Gentyala

Joined: Sep 23, 2003
Posts: 17
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,

Balaji Loganathan
author and deputy

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

Spritle Software Blogs
Lasse Koskela

Joined: Jan 23, 2002
Posts: 11962
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 or 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]
I agree. Here's the link:
subject: XSL Global Parameter
It's not a secret anymore!