s9api and Saxon extensions

Post here questions and problems related to oXygen frameworks/document types.
stsk
Posts: 4
Joined: Fri Sep 11, 2015 9:56 am

s9api and Saxon extensions

Post 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?
alex_jitianu
Posts: 1008
Joined: Wed Nov 16, 2005 11:11 am

Re: s9api and Saxon extensions

Post 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
stsk
Posts: 4
Joined: Fri Sep 11, 2015 9:56 am

Re: s9api and Saxon extensions

Post 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.
Post Reply