cocoon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Rony G. Flatscher" <Rony.Flatsc...@wu-wien.ac.at>
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 BSFEngine.call() ??? 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
a BSF
("Bean Scripting Framework", used in quite a few places of Apache projects) engine not working
(the
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. <http://www2.hursley.ibm.com/rexx/>,
<http://www.rexxla.org/Links/links.html>) running under BSF has been resolved.

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

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

Regards,

---rony

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


-------- Original Message --------
Betreff: A feature suggestion (and a solution to ... Re: [Bsf-discussion] Where's the script
code if
in BSFEngine.call() ??? Request for help.
Datum: Thu, 03 Oct 2002 16:30:25 +0200
Von: "Rony G. Flatscher" <Rony.Flatscher@wu-wien.ac.at>
An: bsf-discussion@www-124.southbury.usf.ibm.com

Hi,

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()
method
  that the code either is passed in as the first argument "object" or as the second argument
"name",
  which seems to not be correct at all!

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

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

  Any help and any hints *very* welcome !

  Regards,

  ---rony
------------------ cut here -----------------

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


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

	<http://nestroy.wi-inf.uni-essen.de/Forschung/rgf/> or
	<http://nestroy.wi-inf.uni-essen.de/Forschung/rgf/bsf4rexx/index.htm>

(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
the
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
be
invoked immediately before "BSFEngine.call()". BSF-languages could then use this to pre-compile
the
code, interpreter-only languages could use this method to get a hold of the source code method
BSFEngine.call() expects to be executed. 

---

Regards,

---rony
Mime
View raw message