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 8218979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T12:59:25+00:00 2026-06-07T12:59:25+00:00

Looking in the Saxon documentation there is a -x:className flag on the command line

  • 0

Looking in the Saxon documentation there is a “-x:className” flag on the command line for specifying a particular SAX parser for use during the application of an XSLT.

How does one achieve this programmatically? I’m using the s9api right now in my code, and I checked the Processor, XsltCompiler, XsltExecutable, and XsltTransformer objects; none of them have any way to set the SAX parser. I also instantiated a net.sf.saxon.Transform, and that didn’t have anything either.

I am most likely looking at the wrong set of objects, but I don’t know how I’m supposed to know what the correct set is.

The command line documentation linked to above mentioned “Use specified SAX parser for source file and any files loaded using the document() function.” I’m sure if I knew what I was doing, this mention of a “document()” function would immediately clue me in. Unfortunately, I do not, and it does not.

Edit: Michael Kay’s answer below is the correct one. (Of course it is! He’s the Saxon guy!) I figured I’d add some sample code for future generations.

First, his solution using net.sf.saxon.s9api.Processor:

Processor processor = new Processor(false);
processor.setConfigurationProperty(FeatureKeys.SOURCE_PARSER_CLASS,
  "fully.qualified.package.name.of.MySAXParser");

In the above, it’s important to supply it the fully-qualified name (and not just the class name) of the SAXParser as a String. If you do the following:

processor.setConfigurationProperty(FeatureKeys.SOURCE_PARSER_CLASS,
  new MySAXParser());

…you will get this:

java.lang.IllegalArgumentException: SOURCE_PARSER_CLASS class must be a String

Second, his solution using net.sf.saxon.s9api.XsltTransformer:

// ^^^ Various setup code to get to this point...
XsltTransformer transformer = xsltExecutable.load();
File file = new File("/path/to/my/file");
InputStream fileInputStream = new FileInputStream(file);
InputSource inputSource = new InputSource(fileInputStream);
Source saxSource = new SAXSource(new MySAXParser(), inputSource);
transformer.setSource(saxSource);
// vvv Set other parameters, actually invoke the transform, etc...

My only issues/caveats are:

1.) The following message is printed out in the console:

Cannot find CatalogManager.properties

This doesn’t seem to affect anything, as the transform still works just fine, and I’m pretty sure it has nothing really to do with Saxon itself, but rather something I’m messing up within the implementation of my custom SAXParser.

2.) If I want to transform a non-XML document (yes, it’s totally possible) I can’t use solution #2, as calling XsltTransform.setSource() causes it to default to viewing the source as an XML document, and will give you the dreaded

Error on line 1 column 1 
  SXXP0003: Error reported by XML parser: Content is not allowed in prolog.

Thus, for transforming non-XML documents, you must use the “coarse-grained” Processor solution.

  • 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-07T12:59:27+00:00Added an answer on June 7, 2026 at 12:59 pm

    If you want to be sure of getting answers to Saxon questions, use the Saxon forums at dev.saxonica.com, or the saxon-help list on SourceForge.

    The answer is: you can use

    Processor.setConfigurationProperty(
        FeatureKeys.SOURCE_PARSER_CLASS, parserClassName)
    

    However, this may be a bit coarse-grained: it works on the command line because the Configuration is set up typically just to transform one document. For finer control, you can always supply input to a transformation in the form of a SAXSource object, which contains an XMLReader, which represents an instance of the SAX parser that you want to use.

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

Sidebar

Related Questions

Looking for a general case solution to determine if any jquery dialog (there are
looking for windows software who can draw a Use Case diagram like yuml.me anyone
Looking at all the examples of Operational Transformation Frameworks out there, they all seem
Looking through the achievement list for Visual Studio 2010, it says that there is
Looking for a better way of extracting a number from the last line in
Looking for simple php class routing, like this: http://fatfree.sourceforge.net/page/routing-engine Is there a ready-made solutions?
Looking at the output of this particular method is confusing to me. I'm trying
Looking through the Django docs and trying to figure out the use of the
looking for a large file upload solution on MVC3. There's a few examples in
I have been looking into IKVMing Apache's FOP project to use with our .NET

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.