Return-Path: Delivered-To: apmail-xml-cocoon-dev-archive@xml.apache.org Received: (qmail 70601 invoked by uid 500); 4 Oct 2002 15:07:21 -0000 Mailing-List: contact cocoon-dev-help@xml.apache.org; run by ezmlm Precedence: bulk list-help: list-unsubscribe: list-post: Reply-To: cocoon-dev@xml.apache.org Delivered-To: mailing list cocoon-dev@xml.apache.org Received: (qmail 78998 invoked from network); 3 Oct 2002 15:36:00 -0000 Message-ID: <3D9C6212.670EC0D6@wu-wien.ac.at> Date: Thu, 03 Oct 2002 17:28:18 +0200 From: "Rony G. Flatscher" X-Mailer: Mozilla 4.78 [de] (Windows NT 5.0; U) X-Accept-Language: de MIME-Version: 1.0 To: cocoon-users@xml.apache.org, cocoon-dev@xml.apache.org 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.] Content-Type: multipart/mixed; boundary="------------E9E0F389AE7FC46A07F6ADF0" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit 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. , ) 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" 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: 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 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 --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="page2html-objectrexx.xsl" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="page2html-objectrexx.xsl" =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= <xsl:value-of select=3D"title"/>=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A=

=0A= =0A= =0A= =0A= =0A= =0A= ../view-source?filename=3D/=0A= _blank=0A= =0A= =0A= =0A=

=0A=
=0A= =0A= =0A=

=0A= =0A=

=0A=
=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= = =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="page2fo-javascript.xsl" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="page2fo-javascript.xsl" =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= Page: =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= 7) {=0A= var data =3D "The difference between the due date: " + = due_date + " and today: " + now + " are " + days + " days and sorry, we = can't accept your delay!";=0A= return data;=0A= }=0A= else if (days =3D=3D 7) {=0A= var data =3D "The difference between the due date:: " + = due_date + " and today: " + now + " are" + days + " days and lucky you, = we still tolerate this!";=0A= return data;=0A= }=0A= else {=0A= var data =3D "It's already done!";=0A= return data;=0A= }=0A= }]]>=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="page2fo-objectrexx.xsl" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="page2fo-objectrexx.xsl" =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= Page: =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="hello-page.xml" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="hello-page.xml" =0A= =0A= =0A= =0A= =0A= =0A= =0A= ]>=0A= =0A= =0A= XSL-Transformation of a XML-file to a HTML-file or to a = PDF-file=0A= =0A= This is an output of an xsl-transformation of an xml-file to a = html-file or a pdf-file, using bsf (bean scripting framework) and a = Javascript or a (object)rexx script.=0A= =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="sitemap.xmap" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="sitemap.xmap" =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/xml; charset=iso-8859-1; name="page2html-javascript.xsl" Content-Transfer-Encoding: quoted-printable Content-Disposition: inline; filename="page2html-javascript.xsl" =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= <xsl:value-of select=3D"title"/>=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A=

=0A= =0A= =0A= =0A= =0A= =0A= ../view-source?filename=3D/=0A= _blank=0A= =0A= =0A= =0A=

=0A=
=0A= =0A= =0A=

=0A= =0A=

=0A=
=0A= =0A= =0A= =0A= =0A= =0A= =0A= =0A= 7) {=0A= var data =3D "The difference between the due date: " + = due_date + " and today: " + now + " are " + days + " days and sorry, we = can't accept your delay!";=0A= return data;=0A= }=0A= else if (days =3D=3D 7) {=0A= var data =3D "The difference between the due date:: " + = due_date + " and today: " + now + " are" + days + " days and lucky you, = we still tolerate this!";=0A= return data;=0A= }=0A= else {=0A= var data =3D "It's already done!";=0A= return data;=0A= }=0A= }]]>=0A= =0A= =0A= =0A= =0A=

=0A=

=0A=
=0A= =0A= =0A= =0A= =0A= --------------E9E0F389AE7FC46A07F6ADF0 Content-Type: text/plain; charset=us-ascii --------------------------------------------------------------------- To unsubscribe, e-mail: cocoon-dev-unsubscribe@xml.apache.org For additional commands, email: cocoon-dev-help@xml.apache.org --------------E9E0F389AE7FC46A07F6ADF0--