Newbie - External Java function

Here should go questions about transforming XML with XSLT and FOP.
tmakita
Posts: 116
Joined: Fri Apr 08, 2011 7:58 am

Newbie - External Java function

Post by tmakita »

Hi,
I'm using oXygen 13 for DITA-OT plug-in stylesheet development. My stylesheet uses external Java function as follows:

<xsl:stylesheet version="2.0"
xmlns:fo="http://www.w3.org/1999/XSL/Format"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:ahf="http://www.antennahouse.com/names/XSLT/ ... s/Document"
xmlns:axf_xsltutils-saxon="java:jp.co.antenna.axf_xsltutils.SetScript"
xmlns:axf_xsltutils-xalan="xalan://jp.co.antenna.axf_xsltutils.SetScript"
extension-element-prefixes="axf_xsltutils-saxon axf_xsltutils-xalan"
exclude-result-prefixes="axf_xsltutils-saxon axf_xsltutils-xalan xs ahf"
>
...
<xsl:copy-of select="axf_xsltutils-saxon:setScriptSaxon(string($prmText),'&#x2202;&#x2206;&#x220F;&#x2211;&#x2212;&#x2215;&#x2219;&#x221A;&#x221E;&#x221F;&#x2229;&#x222B;&#x2248;&#x2260;&#x2261;&#x2264;&#x2265;','Latn')"/>

I added to the corresponding .jar file to the oXygen project file. But in the XSLT stylesheet editing window Saxon outputs the following errror.

"SystemID: D:\DITA-OT1.5.1-FB\plugins\ye_pdf\xsl\ye_dita2fo_bodyelement.xsl
Main validation file: D:\DITA-OT1.5.1-FB\plugins\ye_pdf\xsl\ye_dita2fo_shell.xsl
Scenario name: ye_dita2fo
Engine name: Saxon-EE 9.3.0.5
Severity: fatal
Description: Cannot find a matching 3-argument function named {java:jp.co.antenna.axf_xsltutils.SetScript}setScriptSaxon(). For diagnostics on calls to Java methods, use the -TJ command line option or set the Configuration property FeatureKeys.TRACE_EXTERNAL_FUNCTIONS
Start location: 1318:84
URL: http://www.w3.org/TR/xpath20/#ERRXPST0017"

It seems that Saxon cannot recognize the extension function. But this function works in the actual transform in DITA-OT (Not in oXygen).

Do you have any solution to fix this error message?

Thanks,

Toshihiko Makita
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Radu
Posts: 9438
Joined: Fri Jul 09, 2004 5:18 pm

Re: Newbie - External Java function

Post by Radu »

Hi,
I added to the corresponding .jar file to the oXygen project file.
You have to add the additional JAR library to the set of libraries Oxygen uses to start the DITA OT ANT transformation.
You can edit your transformation scenario, go to the Advanced tab, click the Libraries button and add your additional library in the list.

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tmakita
Posts: 116
Joined: Fri Apr 08, 2011 7:58 am

Re: Newbie - External Java function

Post by tmakita »

Hi Radu,
Thank you for your reply.
You have to add the additional JAR library to the set of libraries Oxygen uses to start the DITA OT ANT transformation.
You can edit your transformation scenario, go to the Advanced tab, click the Libraries button and add your additional library in the list.
Yes, according to your suggestion I configureed transformation scenario. If I invoke XSLT processing it works fine. However in the editing mode, I still get the error message written above.

What is the solution in the XSLT stylesheet editing?

Regards,
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Radu
Posts: 9438
Joined: Fri Jul 09, 2004 5:18 pm

Re: Newbie - External Java function

Post by Radu »

Hi Toshihiko,

You can create and associate a validation scenario to the XSLT:

http://www.oxygenxml.com/doc/ug-editor/ ... nario.html

That validation scenario allows you to configure a list of extension libraries which will be used to validate the XSL.

This screenshot I made should help:

http://www.oxygenxml.com/forum/files/va ... enario.png

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tmakita
Posts: 116
Joined: Fri Apr 08, 2011 7:58 am

Re: Newbie - External Java function

Post by tmakita »

Hi Radu,

I configured according to your suggestion. However the validation error still exists. Please refer to the following screen image.

http://www.antenna.co.jp/temp/oxygen/diff_20111201.png

This stylesheet actually works with .jar Java libray.

Please help!

Regards,

Toshihiko Makita
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Radu
Posts: 9438
Joined: Fri Jul 09, 2004 5:18 pm

Re: Newbie - External Java function

Post by Radu »

Hi Toshihiko,

You shouldn't have added the JAR as an additional validation module.
The list of validation modules is like a cascade, the XSL is validated against all modules specified in the list.
The first validation module has a small button in the right hand side which you can press to add the JAR to the Libraries list.
Please see the corrections I made to your image:

http://www.oxygenxml.com/forum/files/ad ... ctions.png

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tmakita
Posts: 116
Joined: Fri Apr 08, 2011 7:58 am

Re: Newbie - External Java function

Post by tmakita »

Hi Radu,

Thank you for your indication.

I added .jar file to the library list and tried to validate. Please refer to the following .png snap shot. The error message still exists.

http://www.antenna.co.jp/temp/oxygen/di ... 1201_2.png

I added jar command result. The stylesheet really works with this library.

D:\DITA-OT1.5.1-FB\plugins\ye_pdf\lib>c:\progra~1\java\jdk1.6.0_26\bin\jar -tvf
axf_xsltutils.jar
25 Wed Mar 18 10:06:50 JST 2009 META-INF/MANIFEST.MF
389 Tue Mar 10 10:24:00 JST 2009 .project
232 Tue Mar 10 10:24:38 JST 2009 .classpath
9852 Wed Mar 18 10:03:48 JST 2009 jp/co/antenna/axf_xsltutils/SetScript.class

D:\DITA-OT1.5.1-FB\plugins\ye_pdf\lib>

What is wrong with me?

Regards,

Toshihiko makita
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Radu
Posts: 9438
Joined: Fri Jul 09, 2004 5:18 pm

Re: Newbie - External Java function

Post by Radu »

Hi Toshihiko,

My indications were for validating the XSL document.
From what I see in the screenshot, you are debugging it.
The debugger has its own button for adding JAR extensions to be used while debugging:

http://www.oxygenxml.com/doc/ug-oxygen/ ... olbar.html

There is a "Libraries" button on the debugger control panel.

I do not quite understand what you are trying to debug, your stylesheet being a module.
Are you trying to debug part of a DITA transformation?
Then you should try to debug by opening the main DITA XSL (the dita2fo_shell.xsl) and the merged DITAMap (which resulted after the DITA OT pre-processing stage).

Regards,
Radu
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
tmakita
Posts: 116
Joined: Fri Apr 08, 2011 7:58 am

Re: Newbie - External Java function

Post by tmakita »

Hi Radu,
My indications were for validating the XSL document.
Yes, I understand.
From what I see in the screenshot, you are debugging it.
No! I am using oXygen for editing XSL files and validation only.

But when I configured the validation scenario to use explicitly Saxon-PE 9.3.0.5 instead of <Default engine>, the error message suddenly disappeared!

http://w01.tp1.jp/~a190498571/png/success_20111201.png

Anyway I'm very satified this result. I appreciate your help.

Thank you for your help!

Regards,
--
/*--------------------------------------------------
Toshihiko Makita
Development Group. Antenna House, Inc. Ina Branch
Web site:
http://www.antenna.co.jp/
http://www.antennahouse.com/
--------------------------------------------------*/
Post Reply