Page 1 of 1

s9api and Saxon extensions

Posted: Tue Aug 09, 2016 2:01 pm
by stsk
I have an extension plugin for oXygen 18. One of the purposes of the plugin is to allow users to convert various XML formats. All conversions are done in XSLT via the s9api interface from saxon9ee.jar. I have had no issues with this approach until I tried adding a Saxon extension function, specifically saxon:serialize(), to one of the stylesheets, which results in this error when the stylesheet is compiled:

Code: Select all

XPST0017 XPath syntax error at char 8 on line 32 near {...katalogpost>\s+</katalogpos...}:
Cannot find a matching 2-argument function named {http://saxon.sf.net/}serialize().
Saxon extension functions require a Saxon-PE or Saxon-EE license
The stylesheet in question works perfectly fine when I run it in the XSLT debugger. How do I enable extension functions in s9api? My Processor instance is created with Processor(true) and reports "EE" as its edition. Is it really the case that XSLT functionality which exists in oXygen itself is not available to plugin developers?

Re: s9api and Saxon extensions

Posted: Wed Aug 10, 2016 11:40 am
by alex_jitianu
Hello,

From an Workspace Access plugin you can create a Saxon EE transformer:

Code: Select all

pluginWorkspaceAccess.getXMLUtilAccess().createXSLTTransformer(
styleSource,
extensionJars,
XMLUtilAccess.TRANSFORMER_SAXON_ENTERPRISE_EDITION,
false)
You will get a JAXP transformer that you can use to transform the XSL document. Is it O.K. for you to rewrite the code to use JAXP instead of the s9api ?

If an Oxygen plugin uses Saxon API, that Saxon instance will have access to Oxygen's inner Saxon license. I've tested myself using a Processor and I managed to execute a saxon:serialize(). Are you creating ClassLoaders in this plugin to load a different saxon9ee.jar?

Best regards,
Alex

Re: s9api and Saxon extensions

Posted: Wed Aug 10, 2016 1:38 pm
by stsk
Hi Alex,

You're right, it does work. My issue was that I was using the wrong constructor.

For future reference in case anyone is interested: You have to supply the Processor with a proper Configuration (e.g. by calling Configuration.makeLicensedConfiguration()). The boolean constructor is insufficient.