This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

XSL Global Parameter

 
Hari Shankar Gentyala
Greenhorn
Posts: 17
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Balaji Loganathan
author and deputy
Bartender
Posts: 3150
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Lasse Koskela
author
Sheriff
Posts: 11962
5
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic