Registering Custom Extension for Saxon HE
Here should go questions about transforming XML with XSLT and FOP.
-
- Posts: 16
- Joined: Mon Jan 10, 2011 6:02 pm
Registering Custom Extension for Saxon HE
Hi all. I'm working on a custom extension in order to provide some functions to XSLT by Saxon.
My firs approach was to test Saxon EE provided by Oxigen itself: I created a simple java class, put it in a jar and place this jar in <oxigenx install dir>/lib. Then declaring a namespace such xmlns:see="it.mypackage.MyExtensionClass" it is possible to use the method in a very simple way, calling the method as a normal function:
<xsl:value-of select="see:getString('testo di prova')"/>
By reflection implemented in Saxon EE, it works like a charm, and Oxygen can validate the function and parameters type too
(thanks Saxon, thanks Oxygen).
Second approach was porting such extension on Saxon HE. I created my extension accordingly with info provided on Saxonica and SourceForge web sites. I was able to compile the extension in a jar. Unfortunately indicate the extension in XSLT Scenario is not enough: the transformer is unable to access extension.
What I'm missing? I must create some kind of wrapper or custom XSLT Transformer?
My firs approach was to test Saxon EE provided by Oxigen itself: I created a simple java class, put it in a jar and place this jar in <oxigenx install dir>/lib. Then declaring a namespace such xmlns:see="it.mypackage.MyExtensionClass" it is possible to use the method in a very simple way, calling the method as a normal function:
<xsl:value-of select="see:getString('testo di prova')"/>
By reflection implemented in Saxon EE, it works like a charm, and Oxygen can validate the function and parameters type too

Second approach was porting such extension on Saxon HE. I created my extension accordingly with info provided on Saxonica and SourceForge web sites. I was able to compile the extension in a jar. Unfortunately indicate the extension in XSLT Scenario is not enough: the transformer is unable to access extension.
What I'm missing? I must create some kind of wrapper or custom XSLT Transformer?
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Registering Custom Extension for Saxon HE
Post by sorin_ristache »
Hello,
Yes, you have to write a small Java class that starts the Saxon HE transformer. This is necessary because in Saxon HE your extension functions must be registered in a net.sf.saxon.Configuration object which you set to the Saxon HE transformer factory class (net.sf.saxon.TransformerFactoryImpl) with a call transformerFactory.setAttribute(net.sf.saxon.lib.FeatureKeys.CONFIGURATION, yourConfiguration). This call must be done before the factory creates the transformer, that is before the TransformerFactory.newTransformer() call. You can call your small Java class as an external XSLT processor in Oxygen.
Regards,
Sorin
Yes, you have to write a small Java class that starts the Saxon HE transformer. This is necessary because in Saxon HE your extension functions must be registered in a net.sf.saxon.Configuration object which you set to the Saxon HE transformer factory class (net.sf.saxon.TransformerFactoryImpl) with a call transformerFactory.setAttribute(net.sf.saxon.lib.FeatureKeys.CONFIGURATION, yourConfiguration). This call must be done before the factory creates the transformer, that is before the TransformerFactory.newTransformer() call. You can call your small Java class as an external XSLT processor in Oxygen.
Regards,
Sorin
-
- Posts: 16
- Joined: Mon Jan 10, 2011 6:02 pm
Re: Registering Custom Extension for Saxon HE
thanks Sorin for your replay, that confirmed my suspects 
Well, supposing I would like to run such java class as a different xslt engine (say, CustomSaxon) inside the Oxygen IDE: is it possible to do? Can I configure a scenario that works with my CustomSaxon? And what parameter I must manage inside the class (i.e. of course, xml file, xsl file and output file, probably there are more?)
Thanks.

Well, supposing I would like to run such java class as a different xslt engine (say, CustomSaxon) inside the Oxygen IDE: is it possible to do? Can I configure a scenario that works with my CustomSaxon? And what parameter I must manage inside the class (i.e. of course, xml file, xsl file and output file, probably there are more?)
Thanks.
-
- Posts: 4141
- Joined: Fri Mar 28, 2003 2:12 pm
Re: Registering Custom Extension for Saxon HE
Post by sorin_ristache »
Yes, you can configure an external XSLT transformer based on your small Java class from menu Options -> Preferences -> XML -> XSLT-FO-XQuery -> Custom Engines. You have to select the created transformer in the Transformer combo box of your XSLT transformation scenario. Please look at the example of command line for an external engine in the User Manual. You specify the XML URL and XSL URL from the scenario in the command line of the external transformer using the ${xml} and ${xsl} editor variables. You can find the list of all available editor variables in the dialog box for configuring a custom engine by pressing the small green arrow button next to the Command Line text area.
Regards,
Sorin
Regards,
Sorin
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ Artificial Intelligence (AI Positron Assistant add-on)
- ↳ 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