Page 1 of 1

Java Extensions in XSLT debugger

Posted: Thu May 27, 2004 6:05 pm
by Stinger
Hi,

I am evaluating your XSLT-debugger (oxygenxml version 4.0 under suse linux 9.1) and have found it quite useful with exception to one thing:

It seems to not recognize my Java-Extension-Bindings that I have declared and that are called in the stylesheet.

When the debugger comes to a java call, it e.g. prints the following error:
F The URI http://www.quinscape.de/InsertXMLDeclaration does not identify an external Java class resolvedruckordnung_test.xsl file:/home/ajans/drucksystem/Drucksystem/bin/resolvedruckordnung_test.xsl
The declaration is as following:

Code: Select all


<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xmldecl="http://www.quinscape.de/InsertXMLDeclaration"
xmlns:majix="http://www.quinscape.de/com.tetrasix.majix.MajixBatch" exclude-result-prefixes="xmldecl majix">
and the corresponding call for the first declaration is:

Code: Select all


<xsl:variable name="dummy" select="xmldecl:insertXMLDeclaration(string($filetoload),string($prefile),'ISO-8859-1')"/>
The named Java-class is in the anonymous package, but the same error occurs with a named package.
I use Saxon 6.5.3 for processing and validating, and the xslt works outside of oxygenxml.
I also tried adding the required Java-Class and jar-files to the classpath-variable in the script oxygen.sh and the file oxygen.lax but no success.

Are Java-Extensions supported, and if so, how should they be declared for debugging-purposes, where and how do I add the required java-files to the classpath?

Thanks for your support.

Arne Jans

Posted: Fri Jun 04, 2004 12:53 pm
by iulian_velea
Hi,

I tested the debugger with Xalan Extensions using the following stylesheet:
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
version="1.0"
xmlns:redirect="http://xml.apache.org/xalan/redirect"
extension-element-prefixes="redirect">

<xsl:template match="/">
<standard-out>
Standard output:
<xsl:apply-templates/>
</standard-out>
</xsl:template>

<xsl:template match="main">
<main>
<xsl:apply-templates/>
</main>
</xsl:template>

<xsl:template match="/doc/foo">
<redirect:write select="@file">
<foo-out>
<xsl:apply-templates/>
</foo-out>
</redirect:write>
</xsl:template>

<xsl:template match="bar">
<foobar-out>
<xsl:apply-templates/>
</foobar-out>
</xsl:template>

</xsl:stylesheet>
And the XML file:
<doc>
<foo file="foo.out">
Testing Redirect extension:
<bar>A foo subelement text node</bar>
</foo>
<main>
Everything else
</main>
</doc>
This is an example from : http://xml.apache.org/xalan-j/extension ... x-redirect

In order for the example to work I added bsf.jar file, which comes with Xalan, to the lib directory where Oxygen is installed, or to the classpath in the script. In both cases it worked.
So what you need to do is to add your jar files in the same manner, and restart the application.

Best Regards,
Iulian

BSF and javascript xslt extension support

Posted: Mon Jun 07, 2004 1:36 am
by alexfr
Hi,

I made a copy of both bsf.jar and js.jar (for javascript support) in oXygen lib repertory. I tried the exemple provided by apache :

http://xml.apache.org/xalan-j/extensions.html#ex-basic

But I got a NullPointerException error

Did I miss a config set-up ?

Posted: Fri Jun 11, 2004 2:16 pm
by sorin_ristache
Hello alexfr,

Yes, your set-up is the cause of the NullPointerException. Do not use a version of the Rhino JavaScript library (js.jar) later than 1.5R4.1 because there are undocumented runtime incompatibilities with the BSF scripting support (bsf.jar) used by the Xalan processor (js.jar is not bundled with Xalan so the Apache folks may have not tested against Rhino 1.5R5). Instead of using js.jar from Rhino 1.5R5 or later please use Rhino 1.5R4.1 from ftp://ftp.mozilla.org/pub/mozilla.org/js/rhino15R41.zip and the transformation will not fail any more.

Regards,
Sorin

Posted: Fri Jun 11, 2004 6:06 pm
by sorin_ristache
Dear Arne Jans (aka Stinger),

You should be careful to the following issues:

- if you want to put your Java extesion classes in a jar file then copy the jar file in the lib subdirectory of your <oXygen/> installation directory and then restart <oXygen/>;

- alternatively if you want to use directly the Java classes containing your XSLT extensions make sure you copy the classes with their corresponding directory structure (for a class package1.package2.YourClass.java make a directory package1/package2 in the lib subdirectory of your <oXygen/> installation directory and copy YourClass.class in the created package2 directory) and then restart <oXygen/>;

- for Saxon extensions, in the debugger perspective choose Saxon instead of Xalan in the XSLT engine combo.

Best regards,
Sorin

Posted: Wed Jul 14, 2004 6:31 pm
by geejee
Sorin,

what you wrote works quite nicely for the standalon version of oXygen.
When trying to do the same thing with the Eclipse plugin, things do not go as smoothly. Would it be possible to add custom extensions in the eclipse plugin?

I have tried to put a jar containing my java classes in the lib directory of the eclipse plugin and have messed around with the plugins config file, but it did not work and I got a ClassNotFoundException during the transformation.

Also what I would like to have is a configuration option that would say: add these libraries / jars to the classpath while doing the transformation. This would be an option in the "Configure Transformation Scenario" menu / tool.

regards.

Posted: Fri Jul 16, 2004 2:22 pm
by geejee
I saw today that in version 4.2 there is an option to extend the classpath. I did get this to work with the standalone version. Getting it to work in Eclipse did not work, in the user guide for the plugin it is sort of mentioned that this should be possible, but the description is identical to the description in the user guide for the standalone version. Is this feature at all supported in the plugin and if so how can it be enabled?

Posted: Fri Jul 16, 2004 5:05 pm
by tavy
Hi,

I tested <oXygen/> Eclipse Plugin 4.2 with Xalan Extensions using the example from: http://xml.apache.org/xalan-j/extensions.html#ex-basic.

To make this work follow the next steps:
1. Copy js.jar and bsf.jar in [oxygen]/lib directory.
2. Edit pugin.xml from oxygen base directory and add the following lines:

Code: Select all


<library name="lib/js.jar">
<export name="*"/>
<packages prefixes="org.mozilla.javascrpt"/>
</library>
<library name="lib/bsf.jar">
<export name="*"/>
<packages prefixes="com.ibm.bsf"/>
</library>
3. Delete all from [eclipse]/configuration directory (but not config.ini).
4. Restart Eclipse.
5. Test by configurating and running a transformation scenario using the Xalan transformer.

The "Configuring the extension paths for transformer processors" from the user guide was ment only for the standalone version. We will remove it from the Eclipse plugin user guide.