This week's book giveaway is in the OCMJEA forum.
We're giving away four copies of OCM Java EE 6 Enterprise Architect Exam Guide and have Paul Allen & Joseph Bambara 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 OCM Java EE 6 Enterprise Architect Exam Guide this week in the OCMJEA 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: 73
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.

It is sorta covered in the JavaRanch Style Guide.
subject: XSLT calling Java methods