This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
The moose likes XML and Related Technologies and the fly likes XSLT calling Java methods Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "XSLT calling Java methods" Watch "XSLT calling Java methods" New topic

XSLT calling Java methods

Payam Fard
Ranch Hand

Joined: Jan 31, 2003
Posts: 75
How can I make calls to Java inside my xslt code? I have the following needs:

1) Include Java Date
2) Pass some variable values to be included in the xml document that is generated by the xslt.

Any pointers would be helpful.

Craig Bayley
Ranch Hand

Joined: Sep 27, 2007
Posts: 46
Most transformers allow you to pass in parameters:

In the transform you initialise this parameter at the top of the stylesheet, and if you pass in a parameter it will be overriden with whatever you passed in.

In terms of calling java from within xslt...erm...Why, architecturally, would you want to be in that position? Can't help on that one, I'm afraid.
Roseanne Zhang
Ranch Hand

Joined: Nov 14, 2000
Posts: 1953
Hi, Payam Fard

Here are two examples I wrote several years ago. I think it will give you a head start.

If you meet any problems, please let me know.

I agree. Here's the link:
subject: XSLT calling Java methods
It's not a secret anymore!