cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <>
Subject BSF: defining XSLT extensions with scripting languages [Fwd: A feature suggestion (and a solution to ... Re: [Bsf-discussion] Where's the script code if in ??? Request for help.]
Date Thu, 03 Oct 2002 15:28:18 GMT
Hi there,

a couple of weeks ago I misplaced a posting in the Cocoon-listserver lists with respect to
("Bean Scripting Framework", used in quite a few places of Apache projects) engine not working
correct place was Xalan and BSF).

This message is just to state, that BSF works and that the problem I ran into my own implementation
of a scripting language (Rexx, cf. <>,
<>) running under BSF has been resolved.

In order to present the entire case, I forward you the message clarifying the problem and
resolution mostly for BSF developers. 

In addition you will find those files attached, which demonstrate how to define and use an
to XSLT, where the function is implemented in Rexx and JavaScript. Maybe that helps the one
or other
solve problems.



P.S.: I will be subscribed to the Cocoon lists for a week in case there are questions w.r.t.

-------- Original Message --------
Betreff: A feature suggestion (and a solution to ... Re: [Bsf-discussion] Where's the script
code if
in ??? Request for help.
Datum: Thu, 03 Oct 2002 16:30:25 +0200
Von: "Rony G. Flatscher" <>


on 2002-09-17 I sought help for the following problem:

------------------ cut here -----------------
  Hi there,

  in the course of tracing down a particular problem with a particular BSFEngine it turns
out that
  it's call() method does *not* supply the script code to be executed, but rather the name
of the
  function/method to be invoked and optional arguments.

  So, could anyone shed some light where one could find the script code in such a situation?

  [The problem occurred for the first time with the RexxEngine, which assumes in the call()
  that the code either is passed in as the first argument "object" or as the second argument
  which seems to not be correct at all!

  As Apache's Cocoon (acutally Xalan) employs BSF it would be very productive, if one could
  XSLT-extensions using the Rexx language.

  But at the moment I am clueless, where to locate/retrieve the script-code to be executed/passed
  the Rexx interpreter; the name of the function as well as the arguments arrive as expected.]

  Any help and any hints *very* welcome !


------------------ cut here -----------------

In the meantime I found the solution, thanks to the very kind help of one of Xalan's developers
informed me, that prior to invoking the method BSFEngine.exec() is invoked,
so that
it becomes possible for scripting engines to compile the script (if possible for that language

So the solution was to "catch" the source in method BSFEngine.exec() and use it for invocation
method The appropriately adjusted and RexxEngine.class can
found at:

	<> or

(You could point either to the bsf*.jar in the above package or extend your BSF environment
with the
above Rexx BSF engine.)

The attached files, originally created by Gerald Michalitz, demonstrate the usage of the XSLT
extension mechanism via BSF in Apache's Xalan (the Java implementation). As a matter of fact
supplied files allow you to use Apache's "publishing frontend" Cocoon for testing purposes:
this way
one can use any of the BSF-supported languages to create functions which can be used/invoked
in the
XSL-transformation process. 

*Very* powerful stuff. Hence, I thought this might be interesting for readers of this list
(users as
well as developers). Mereley replace the Rexx-code with your language's code and adjust the
programming language attribute to contain the name known to BSF.


FEATURE SUGGESTION for BSF: For purposes like this BSF *should* define a method
"BSFEngine.prepareScript()" with the same signature as BSFEngine.apply(): this method should
invoked immediately before "". BSF-languages could then use this to pre-compile
code, interpreter-only languages could use this method to get a hold of the source code method expects to be executed. 



View raw message