The classes StAXOMBuilder and OMElement appear to be part of the Apache AXIOM product. There is no integration between Saxon and Axiom.
However, the only problem this causes is that I can't run your code: it's easy to change your example so it doesn't use these classes, but just binds an XMLStreamReader to the source XML file directly.
This then leads to the question of whether Saxon should recognize the net.sf.saxon.transform.StAXSource class.  To be honest, I have no idea where this class came from. It's in JDK 1.6, and it claims in the Javadoc that it's part of JSR 173, but if you go to the JSR 173 specification, or to the free-standing JAR files distributed with JSR 173, then it's not there. I can't find any version of this class that's available for use with JDK 1.4 or JDK 1.5, and if that's the case then it means that it can't be used with Saxon.
Incidentally, the claim in the Javadoc that "StAXSource can be used in all cases that accept a Source, e.g. Transformer, Validator which accept Source as input. " is absurd. A new implementation of Source, unless it subclasses an existing supported implementation such as SAXSource, will only work with software that has been modified to recognize it.
I will raise these questions with the JAXP expert group and see if they can shed any light.
Meanwhile, if you want to use an XMLStreamReader to provide input to a transformation, you can use a net.sf.saxon.pull.PullSource, which wraps an instance of net.sf.saxon.pull.StaxBridge:
StaxBridge bridge = new StaxBridge();
PullSource source = new PullSource(bridge);
transformer.transform(source, result)
Michael Kay

From: Luis Costa []
Sent: 04 February 2009 10:17
Subject: [saxon] StAXSource as sorce to perform transformation usingsaxonb9-1-0-5j problem

Hi all,

I’m trying to validate a xml to a schematron,

1.       I transform my shematron code to a stylesheet;

2.       I submit the xml to the stylesheet as you can see below A)

3.       I’m using the latest version of saxon(saxonb9-1-0-5j) and I’m getting the following error B) (net.sf.saxon.trans.XPathException: A source of type javax.xml.transform.stax.StAXSource is not supported in this environment)



1.       Is this a known error?

2.       What is your advice?


Many thanks,

Luis Costa




String strStylSheetPath = "C:/dummy.xsl";

String omElemPath = "C:/ dummy.xml";

InputStream imp = new FileInputStream(new File(omElemPath));

InputStreamReader impsr = new InputStreamReader(imp);

Reader reader = impsr;

XMLStreamReader parser = null;

try {

                parser = XMLInputFactory.newInstance().createXMLStreamReader(reader);

} catch (XMLStreamException e) {



} catch (FactoryConfigurationError e) {



StAXOMBuilder builder = new StAXOMBuilder(parser);

OMElement omMetadata =  builder.getDocumentElement();

FileInputStream fileInputStream = new FileInputStream(strStylSheetPath);

Source srcStylSheet = new StreamSource(fileInputStream);

System.setProperty("javax.xml.transform.TransformerFactory", TransformerFactoryImpl.class.getName());

Transformer xDSFieldsValidationStylesheet = TransformerFactoryImpl.newInstance().newTransformer(srcStylSheet);

Source src = new StAXSource(omMetadata.getXMLStreamReader());

ByteArrayOutputStream bos = new ByteArrayOutputStream();

Result rs = new StreamResult(bos);



// this fails …

xDSFieldsValidationStylesheet.transform(src, rs);


catch(Exception e)








net.sf.saxon.trans.XPathException: A source of type javax.xml.transform.stax.StAXSource is not supported in this environment





Thank you for your attention and best regards,


Luís Costa

Software Developer



ALERT Life Sciences Computing, S.A.

Edifício Lake Towers – pisos 7, 8 e 9

Rua Daciano Baptista Marques, n.º 245

4400-617 Vila Nova de Gaia


Tel.: +351 22 832 89 80

Fax.: +351 22 832 89 82


This e-mail is privileged, confidential and contains private information. Any reading, retention, distribution or copying of this communication by any person other than its intended recipient is prohibited.