Project

Profile

Help

Support #5466

closed

saxon-pe 11.3 seems it to use the opensource version

Added by Erez Harari almost 2 years ago. Updated almost 2 years ago.

Status:
Closed
Priority:
Normal
Assignee:
-
Category:
-
Sprint/Milestone:
-
Start date:
2022-04-30
Due date:
% Done:

0%

Estimated time:
Legacy ID:
Applies to branch:
11
Fix Committed on Branch:
Fixed in Maintenance Release:
Platforms:
Java

Description

Trying saxon-pe and it seems it uses the opensource version: I set -Djavax.xml.transform.TransformerFactory=com.saxonica.config.ProfessionalTransformerFactory I have put the license file in the classpath. When I check the transformer class created its always: class net.sf.saxon.jaxp.TransformerImpl There is no license exception.

Actions #1

Updated by Michael Kay almost 2 years ago

Please (a) show the code you are using to create the TransformerFactory, and (b) try running with the system property jaxp.debug set to 1 (which should give some diagnostics).

The most likely explanation for this is that there is a copy of Saxon-HE on your classpath, which was found by the JAXP loader before it found the Saxon-PE jar.

Actions #2

Updated by Erez Harari almost 2 years ago

Actually I was using the JAXP way. Now I switched to the s9api and running in junit limited test. Still I get net.sf classes rather than com.saxonica.

Processor processor = new Processor(true); XsltCompiler xsltCompiler = processor.newXsltCompiler(); xslStream = new StringInputStream(xsl);

//THREAD SAFE: can be used as often as you like, in the same thread or in different threads. XsltExecutable xsltExecutable = excutableCache.get(xsl); if (xsltExecutable == null) { synchronized (excutableCache) { xsltExecutable = excutableCache.get(xsl); if (xsltExecutable == null) { xslStream = new StringInputStream(xsl); xsltExecutable = xsltCompiler.compile(new StreamSource(xslStream)); excutableCache.put(xsl, xsltExecutable); } } } //NOT THREAD SAFE: can be serially reused, but they must not be shared across multiple threads Xslt30Transformer xsltTransformer = xsltExecutable.load30();

xsltTransformer.transform(xml, new DOMDestination(result.getNode()));

How can I be sure my license is loaded correctly? Is there an API I can invoke at runtime without providing the path to the license file? my license is simply put on the classpath.

Actions #3

Updated by Martin Honnen almost 2 years ago

I think in terms of JAXP, while there are special PE and EE factories (i.e. net.sf.saxon.jaxp.TransformerImpl and net.sf.saxon.jaxp.TransformerImpl, the Transformer you get is an instance of net.sf.saxon.jaxp.TransformerImpl anyway. Only if you want to use JAXP and XSLT 3 streaming and use com.saxonica.config.StreamingTransformerFactory e.g. TransformerFactory transformerFactory = new com.saxonica.config.StreamingTransformerFactory(); explicitly, the Transformer you get is of net.sf.saxon.jaxp.StreamingTransformerImpl.

As for your use of s9api, at which point do you expect to see "commercial" classes? What does processor.getSaxonEdition() show?

Actions #4

Updated by Michael Kay almost 2 years ago

Martin wrote: I think in terms of JAXP, while there are special PE and EE factories (i.e. net.sf.saxon.jaxp.TransformerImpl and net.sf.saxon.jaxp.TransformerImpl, the Transformer you get is an instance of net.sf.saxon.jaxp.TransformerImpl anyway.

Actually, if Saxon-PE is on the classpath, and you call TransformerFactory.newInstance(), then you should get back an instance of com.saxonica.config.ProfessionalTransformerFactory. If you get an instance of net.sf.saxon.jaxp.TransformerImpl this typically means that the JAXP loading mechanism has picked up the Saxon-HE jar from somewhere.

Actions #5

Updated by Michael Kay almost 2 years ago

You say " Still I get net.sf classes rather than com.saxonica. " It would be useful to know more precisely what is failing. Saxon-PE and Saxon-EE include Saxon-HE as a subset, so the existence of net.sf class is not by itself a problem. It's easier to help you if you can explain precisely what you are doing and precisely how it failed.

In particular, we need to establish whether this is a case of loading the wrong JAR file or failing to load the license file.

Note that it's the directory containing the license file that should be on the classpath, not the license file itself.

Have you tried the advice at https://www.saxonica.com/documentation10/index.html#!about/license/checklicense ?

Actions #6

Updated by Martin Honnen almost 2 years ago

Sorry, Mike, for the confusion, the sentence was supposed to say "I think in terms of JAXP, while there are special PE and EE factories (i.e. com.saxonica.config.ProfessionalTransformerFactory and com.saxonica.config.EnterpriseTransformerFactory, the Transformer you get is an instance of net.sf.saxon.jaxp.TransformerImpl anyway." (as the original question complained about "When I check the transformer class created its always: class net.sf.saxon.jaxp.TransformerImpl"). It seems I made a two copy/paste errors without noticing, sorry about that.

Actions #7

Updated by Erez Harari almost 2 years ago

thanks for the quick responses. As said, JAXP is history and now only s9api is in play. Mike, I verified saxon-pe-11.3.jar is the only saxon jar in the classpath Martin, when I run processor.getSaxonEdition() i always get "PE", regardless of putting the license file or removing it. That is my main concern. So, processor.getSaxonEdition() is an API way to check the edition. However, it does not check on the license. How can I check on the license from within my code (API call, not commandline execution)?

Thanks, Erez

Actions #8

Updated by Michael Kay almost 2 years ago

Try

processor.getUnderlyingConfiguration().isLicensedFeature(Configuration.LicenseFeature.PROFESSIONAL_EDITION)

If this is false it means the license file isn't being found: set the configuration property Feature.TIMING for extra diagnostics on this.

[Corrected, first version had a typo]

Actions #9

Updated by Erez Harari almost 2 years ago

Could not find such method as processor.isLicensedFeature()

Actions #10

Updated by Michael Kay almost 2 years ago

Sorry, I corrected a typo after posting.

Actions #11

Updated by Erez Harari almost 2 years ago

Thanks, This works well. Now I can stop my processing when no valid professional license could be found.

I will proceed with my testing.

Many thanks, Erez

Actions #12

Updated by Michael Kay almost 2 years ago

  • Status changed from New to Closed

Closing this as the problem appears to be resolved.

Please register to edit this issue

Also available in: Atom PDF