XSLT with Java extension
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 6
- Joined: Mon May 10, 2010 7:17 pm
XSLT with Java extension
Post by BlackFrancis »
Hello,
I'm using the XSLT capability to import Java functions (using xmlns:java declaration). This works when I perform the transformation as part of my Java application, but when the xslts are loaded in the Oxygen editor, the classes are not found.
Error is:
The URI com.mycompany.Utilities does not identify an external Java class
Is there a way to set a Java classpath in the Oxygen editor, so that this can work in the editor?

I'm using the XSLT capability to import Java functions (using xmlns:java declaration). This works when I perform the transformation as part of my Java application, but when the xslts are loaded in the Oxygen editor, the classes are not found.
Error is:
The URI com.mycompany.Utilities does not identify an external Java class
Is there a way to set a Java classpath in the Oxygen editor, so that this can work in the editor?

-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: XSLT with Java extension
Post by sorin_ristache »
Hello,
You have to set the jar file with your XSLT extensions as an extension of the XSLT transformation scenario (the Extensions button of the dialog).
Regards,
Sorin
You have to set the jar file with your XSLT extensions as an extension of the XSLT transformation scenario (the Extensions button of the dialog).
Regards,
Sorin
-
- Posts: 6
- Joined: Mon May 10, 2010 7:17 pm
Re: XSLT with Java extension
Post by BlackFrancis »
Thank you, that works for executing the transformation within the stand-alone editor.
Is there a similar setting to use, so that when I have the extended XSLT open in the Eclipse plugin, it doesn't flag the extensions as missing functions? The extension classes are part of the current Java project - it would be nice if the plugin picked up the project's class path automatically.
Is there a similar setting to use, so that when I have the extended XSLT open in the Eclipse plugin, it doesn't flag the extensions as missing functions? The extension classes are part of the current Java project - it would be nice if the plugin picked up the project's class path automatically.
-
- Posts: 6
- Joined: Mon May 10, 2010 7:17 pm
Re: XSLT with Java extension
Post by BlackFrancis »
my apologies - that does seem to be the way it works
-
- Posts: 6
- Joined: Mon May 10, 2010 7:17 pm
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XSLT with Java extension
Hello,
You can do the same thing in the Oxygen Eclipse plugin but if you want to use the existing sources you should add the classes(bin) folder of the Java project to the Extensions instead of the jar.
Also, make sure that your project is built automatically.
Regards,
Adrian
You can do the same thing in the Oxygen Eclipse plugin but if you want to use the existing sources you should add the classes(bin) folder of the Java project to the Extensions instead of the jar.
Also, make sure that your project is built automatically.
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: XSLT with Java extension
Post by sorin_ristache »
Hello,
You open the dialog box for adding the XSLT extensions by pressing the Extensions button from the XSLT tab of the scenario dialog box.
Regards,
Sorin
You open the dialog box for adding the XSLT extensions by pressing the Extensions button from the XSLT tab of the scenario dialog box.
Regards,
Sorin
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XSLT with Java extension
Hi,
The dialog Add extension accepts a normal URL(as your web browser). Note that you don't have to enter the URL manually, you can simply browse for a local file(use the Browse button on the right).
e.g. a file URL
Additionally, you can use editor variables to point to various locations known to Oxygen
e.g.
Where ${pdu} is the URL that points to the current project directory(where the Oxygen project file, .xpr, is saved).
Regards,
Adrian
The dialog Add extension accepts a normal URL(as your web browser). Note that you don't have to enter the URL manually, you can simply browse for a local file(use the Browse button on the right).
e.g. a file URL
Code: Select all
file:/D:/frameworks/docbook/xsl/extensions/saxon65.jar
e.g.
Code: Select all
${pdu}/extensions/saxon65.jar
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Tue Nov 08, 2011 5:18 pm
Re: XSLT with Java extension
Using Oxygen v 12
In the extensions dialog for the transform scenario
file://home/jgaer/test.jar
jar -xvf /home/jgaer/test.jar | grep Extensions.class
extracted: com/ticomgeo/web/Extensions.class
jgaer@ljgaer_~:
package com.ticomgeo.web;
public class Extensions {
public static String prependTicomGeo(String s){
return "TICOMGEO"+s;
}
}
Still getting the error
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Saxon-PE 9.3.0.5
Severity: fatal
Description: Cannot find a matching 1-argument function named {java:com.ticomgeo.web.Extensions}prependTicomGeo(). External function calls have been disabled
Start location: 17:60
URL: http://www.w3.org/TR/xpath20/#ERRXPST0017
In the extensions dialog for the transform scenario
file://home/jgaer/test.jar
jar -xvf /home/jgaer/test.jar | grep Extensions.class
extracted: com/ticomgeo/web/Extensions.class
jgaer@ljgaer_~:
package com.ticomgeo.web;
public class Extensions {
public static String prependTicomGeo(String s){
return "TICOMGEO"+s;
}
}
Still getting the error
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Saxon-PE 9.3.0.5
Severity: fatal
Description: Cannot find a matching 1-argument function named {java:com.ticomgeo.web.Extensions}prependTicomGeo(). External function calls have been disabled
Start location: 17:60
URL: http://www.w3.org/TR/xpath20/#ERRXPST0017
-
- Posts: 2879
- Joined: Tue May 17, 2005 4:01 pm
Re: XSLT with Java extension
Hello,
Make sure extension functions are enabled in the Advanced options of Saxon-PE.
Edit the transformation scenario(Document > Transformation > Configure Transformation Scenario, Edit), and in the XSLT tab press the Advanced options(small cogwheel icon) button on the right of the Transformer combo.
At the bottom of the dialog, under Saxon-PE specific options there is an option that has to be enabled: Allow calls on extension functions (-ext)
Regards,
Adrian
Make sure extension functions are enabled in the Advanced options of Saxon-PE.
Edit the transformation scenario(Document > Transformation > Configure Transformation Scenario, Edit), and in the XSLT tab press the Advanced options(small cogwheel icon) button on the right of the Transformer combo.
At the bottom of the dialog, under Saxon-PE specific options there is an option that has to be enabled: Allow calls on extension functions (-ext)
Regards,
Adrian
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
-
- Posts: 6
- Joined: Tue Nov 08, 2011 5:18 pm
Re: XSLT with Java extension
Hi, I enabled the external calls but then found out Saxon HE does not support external calls. We do not have a license for PE. I have switched to xsl 1.0 and xalan but having similar problems , also a bit confused on one point but this may be better asked on a xalan forum.
For xalan I did not see any advanced options ( or options at all for that matter).
Also it is not clear of the protocal component of the namespace URI should be xalan or java, I've found examples of both on the web.
Thanks in advance for any help.
For xalan I did not see any advanced options ( or options at all for that matter).
Also it is not clear of the protocal component of the namespace URI should be xalan or java, I've found examples of both on the web.
Thanks in advance for any help.
-
- Posts: 6
- Joined: Tue Nov 08, 2011 5:18 pm
Re: XSLT with Java extension
Sorry should have included more detail.
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:java_lang="http://xml.apache.org/xalan/java/java.lang"
xmlns:tgi="java://com.ticomgeo.web.Extensions"
exclude-result-prefixes="xs xd"
version="1.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Jan 9, 2012</xd:p>
<xd:p><xd:b>Author:</xd:b> jgaer</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>
<xsl:template match="*">
<root>
<xsl:value-of select="tgi:prependTicomGeo(foo)"></xsl:value-of>
</root>
</xsl:template>
</xsl:stylesheet>
with xalan
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Xalan
Severity: fatal
Description: java.lang.NoSuchMethodException: For extension function, could not find method org.apache.xml.utils.NodeVector.prependTicomGeo([ExpressionContext,] ). - For extension function, could not find method org.apache.xml.utils.NodeVector.prependTicomGeo([ExpressionContext,] ).
with xlstproc
Engine name: Xsltproc
Severity: warning
Description: xmlXPathCompOpEval: function prependTicomGeo not found
Engine name: Xsltproc
Severity: warning
Description: XPath error : Unregistered function
Engine name: Xsltproc
Severity: warning
Description: runtime error: file file:/data/databackup2/migrated/jgaer/Untitled10.xsl line 18 element value-of
Engine name: Xsltproc
Severity: warning
Description: xsltValueOf: text copy failed
Engine name: Xsltproc
Severity: warning
Description: error: file file:/data/databackup2/migrated/jgaer/sample.xml
Engine name: Xsltproc
Severity: warning
Description: xsltRunStylesheet : run failed
Engine name: Xsltproc
Severity: warning
Description: xmlXPathCompOpEval: function prependTicomGeo not found
.....
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Xsltproc
Severity: fatal
Description: The transformer process ended with code: 9
I garnered the syntax for the transform from http://xml.apache.org/xalan-j/extension ... l#java_ext
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:xd="http://www.oxygenxml.com/ns/doc/xsl"
xmlns:java_lang="http://xml.apache.org/xalan/java/java.lang"
xmlns:tgi="java://com.ticomgeo.web.Extensions"
exclude-result-prefixes="xs xd"
version="1.0">
<xd:doc scope="stylesheet">
<xd:desc>
<xd:p><xd:b>Created on:</xd:b> Jan 9, 2012</xd:p>
<xd:p><xd:b>Author:</xd:b> jgaer</xd:p>
<xd:p></xd:p>
</xd:desc>
</xd:doc>
<xsl:template match="*">
<root>
<xsl:value-of select="tgi:prependTicomGeo(foo)"></xsl:value-of>
</root>
</xsl:template>
</xsl:stylesheet>
with xalan
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Xalan
Severity: fatal
Description: java.lang.NoSuchMethodException: For extension function, could not find method org.apache.xml.utils.NodeVector.prependTicomGeo([ExpressionContext,] ). - For extension function, could not find method org.apache.xml.utils.NodeVector.prependTicomGeo([ExpressionContext,] ).
with xlstproc
Engine name: Xsltproc
Severity: warning
Description: xmlXPathCompOpEval: function prependTicomGeo not found
Engine name: Xsltproc
Severity: warning
Description: XPath error : Unregistered function
Engine name: Xsltproc
Severity: warning
Description: runtime error: file file:/data/databackup2/migrated/jgaer/Untitled10.xsl line 18 element value-of
Engine name: Xsltproc
Severity: warning
Description: xsltValueOf: text copy failed
Engine name: Xsltproc
Severity: warning
Description: error: file file:/data/databackup2/migrated/jgaer/sample.xml
Engine name: Xsltproc
Severity: warning
Description: xsltRunStylesheet : run failed
Engine name: Xsltproc
Severity: warning
Description: xmlXPathCompOpEval: function prependTicomGeo not found
.....
SystemID: /data/databackup2/migrated/jgaer/Untitled10.xsl
Engine name: Xsltproc
Severity: fatal
Description: The transformer process ended with code: 9
I garnered the syntax for the transform from http://xml.apache.org/xalan-j/extension ... l#java_ext
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: XSLT with Java extension
Post by sorin_ristache »
Hi,
You have to use:
Regards,
Sorin
Oxygen includes Saxon PE and Saxon EE too, not only Saxon HE. Did you try to set Saxon PE transformer in the dialog box for running the transformation?jeff_gaer wrote:Hi, I enabled the external calls but then found out Saxon HE does not support external calls. We do not have a license for PE.
You did not declare the Xalan extension correctly. If you look at the Xalan page about Java extensions you see:jeff_gaer wrote: xmlns:tgi="java://com.ticomgeo.web.Extensions"
...
I garnered the syntax for the transform from http://xml.apache.org/xalan-j/extension ... l#java_ext
Code: Select all
xmlns:date="http://xml.apache.org/xalan/java/java.util.Date"
Code: Select all
xmlns:tgi="http://xml.apache.org/xalan/java/com.ticomgeo.web.Extensions"
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service