Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8191877
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T04:01:27+00:00 2026-06-07T04:01:27+00:00

This is a simple question, but one I cannot find the answer to. I

  • 0

This is a simple question, but one I cannot find the answer to. I have an XSLT 2.0 stylesheet that I’m trying to process in Java. It relies on XSL elements from Saxon.

My current class works fine with simple XSLT 1.0, but I’m getting errors about unrecognized elements with my 2.0 XSLT built with Saxon.

I cannot figure out how to tell Java to use Saxon as the processor. I’m using javax.xml.transform in my class. Is this a property I can set? What do I set it to?
Thanks!

Edited
I figured out how to set the property to use Saxon, but now I’m getting this error.

Provider net.sf.saxon.TransformerFactoryImpl not found

How do I include Saxon in my application?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T04:01:31+00:00Added an answer on June 7, 2026 at 4:01 am

    There are multiple ways to do this (in order of lookup precedence):

    Direct Instantiation

    Explicitly instantiate the Saxon factory (with a nod to Michael’s comment above):

    TransformerFactory fact = new net.sf.saxon.TransformerFactoryImpl()
    

    This approach means that your code is locked into using Saxon at compile time. This can be seen as an advantage (no risk of it running with the wrong processor) or a disadvantage (no opportunity to configure a different processor at execution time – not even Saxon Enterprise Edition).

    For Saxon-PE, substitute com.saxonica.config.ProfessionalTransformerFactory. For Saxon-EE, substitute com.saxonica.config.EnterpriseTransformerFactory.

    Specify Class Name

    Specify the factory class when constructing it:

    TransformerFactory fact = TransformerFactory.newInstance(
            "net.sf.saxon.TransformerFactoryImpl", null);
    

    Note: available as of Java 6. The Java 5 version does not have this method.

    This approach allows you to choose the processor at execution time, while still avoiding the costs and risks of a classpath search. For example, your application could provide some configuration mechanism to allow it to run with different Saxon editions by choosing between the various Saxon factory classes.

    Use System Property

    Set the javax.xml.transform.TransformerFactory system property before creating an instance:

    System.setProperty("javax.xml.transform.TransformerFactory",    
            "net.sf.saxon.TransformerFactoryImpl");
    

    Or on the command line (line broken for readability):

    java -Djavax.xml.transform.TransformerFactory=
            net.sf.saxon.TransformerFactoryImpl YourApp
    

    This approach has the disadvantage that system properties affect the whole Java VM. Setting this property to select Saxon could mean that some other module in the application, which you might not even know about, starts using Saxon instead of Xalan, and that module could fail as a result if it uses Xalan-specific XSLT constructs.

    Use Properties File

    Create the following file:

    JRE/lib/jaxp.properties
    

    With the following contents:

    javax.xml.transform.TransformerFactory=net.sf.saxon.TransformerFactoryImpl
    

    This approach has similar consequences to using the system property.

    Service Loader

    Create the following file in any JAR on the CLASSPATH:

    META-INF/services/javax.xml.transform.TransformerFactory
    

    With the following contents:

    net.sf.saxon.TransformerFactoryImpl
    

    This approach has the disadvantage that a small change to the classpath could cause the application to run with a different XSLT engine, perhaps one that the application has never been tested with.

    Platform Default

    If none of the above are done, then the platform default TransformerFactory instance will be loaded. A friendly description of this plugability layer can be found here.

    Note that ‘platform’ here means the Java VM, not the hardware or operating system that it is running on. For all current known Java VMs, the platform default is a version of Xalan (which only supports XSLT 1.0). There is no guarantee that this will always be true of every Java VM in the future.

    I’d consider this answer an argument against the Java way of doing things.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a very simple question but cannot find a simple answer. I have
This seems like a simple question, but I have googled it and cannot find
This may be a simple question but I can;t find the answer anywhere. Here
This is a simple question really (but I couldn't seem to find the answer
I have what i thought was a relatively simple question but i cannot find
I am sorry about how simple this question might be, but I cannot find
I have one obviously simple problem, but cannot find good solution, so I would
Hopefully a question with a very simple answer, but it's not one that I've
I think this is a very simple question. but unfortunately I cannot find a
I can't believe that I can't find the answer to this question but I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.