• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

XSL Global Parameter

 
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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 ]
 
reply
    Bookmark Topic Watch Topic
  • New Topic