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 XSLT calling Java methods 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 "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!