The message

org.apache.xerces.jaxp.SAXParserFactoryImpl not found

indicates that despite your best efforts, Xerces is not on the classpath.

That's because when you use the -jar option, Java ignores the -cp option. You need to use

java -cp (classpath) net.sf.saxon.Transform -xsl:... -s:...

Michael Kay

On 14/09/2012 14:02, Patrick Frazer wrote:


I'm working on a project to validate technical journal XML content with a customer-supplied Schematron.  I am able to do so using this sort of command:

java -jar C:\{path}\SaxonHE9-4-0-4J\saxon9he.jar -xsl:C:\{path}\XSLFilename.xsl -s:C:\{path}/InputFilename.sch -o:C:\{path}\OutputFilename.sch  -xi:on

... except that it fails because of an <xsl:include> element used in the Schematron.  The -xi switch is supposed to enable XInclude processing, but the Saxon documentation says "
This currently only works when documents are parsed using the Xerces parser, which is the default in JDK 1.5 and later."

I'm using the JRE 1.6 (not JDK) so I assumed that I needed to download Xerxes 2.11.0, put it in my classpath and configure it with -D switches.  I found some documentation at that seems to describe what I want to do, and following it yielded this attempt:  (linebreaks added for readability)

java \
 -cp C:\
{path}\SaxonHE9-4-0-4J\saxon9he.jar;C:\{path}\xerces-2_11_0\xercesImpl.jar;C:\{path}\xerces-2_11_0\xml-apis.jar;C:\{path}\xerces-2_11_0\resolver.jar;C:\{path}\xerces-2_11_0\serializer.jar \
 -Djavax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl \
 -Djavax.xml.parsers.SAXParserFactory=org.apache.xerces.jaxp.SAXParserFactoryImpl \
 -Dorg.apache.xerces.xni.parser.XMLParserConfiguration=org.apache.xerces.parsers.XIncludeParserConfiguration \
 -jar C:\
{path}\SaxonHE9-4-0-4J/saxon9he.jar \
{path}\iso-schematron-xslt2/iso_dsdl_include.xsl \
{path}\Schematron/JOURNALARTICLE-CURRENT.sch \
{path}\iso-schematron-xslt2/temp1.sch -xi:on

... which throws:

XSLT: Exception in thread "main" javax.xml.parsers.FactoryConfigurationError: Provider org.apache.xerces.jaxp.SAXParserFactoryImpl not found
XSLT:   at javax.xml.parsers.SAXParserFactory.newInstance(Unknown Source)
XSLT:   at
XSLT:   at net.sf.saxon.Configuration.loadParser(
XSLT:   at net.sf.saxon.Configuration.getStyleParser(
XSLT:   at net.sf.saxon.PreparedStylesheet.loadStylesheetModule(
XSLT:   at net.sf.saxon.PreparedStylesheet.prepare(
XSLT:   at net.sf.saxon.PreparedStylesheet.compile(
XSLT:   at net.sf.saxon.Transform.doTransform(
XSLT:   at net.sf.saxon.Transform.main(

I'm not a proficient Java hacker, so it seems to me that by putting the Saxon and Xerces .jar files in the classpath (with -cp) and configuring Xerces with the -D switches would be sufficient, but apparently not.  If anyone has pointers regarding correcting my Java invocation such that I can use the Xerces .jars I downloaded, or how to enable XInclude functionality without it, I would appreciate it.

Thanks for your time.

Patrick Frazer

Got visibility?
Most devs has no idea what their production app looks like.
Find out how fast your code is with AppDynamics Lite.;262219671;13503038;y?

saxon-help mailing list archived at