Page 1 of 1

createXSLTTransformer with custom configuration

Posted: Thu May 21, 2015 1:57 pm
by Patrik
Hi,

I would like to change some transformer configurations for XsltOperations. I already implemented my own AuthorOperation-class for it and replaced the XMLUtilAccess.createXSLTTransformer() with the constrution of a saxon transformer. However, when running it, the messages and errors are not displayed in the oxygen output window and there might be more differences I did not notice yet. Is there a way for me to set up the transformer the same way as it is done inside XMLUtilAccess.createXSLTTransformer() - just with my customized configuration?

Thanks and regards,

Patrik

Re: createXSLTTransformer with custom configuration

Posted: Thu May 21, 2015 4:58 pm
by Radu
Hi Patrik,

We don't have that.
How about if you first call our API to create the transformer and cast it to "net.sf.saxon.jaxp.TransformerImpl", then get the configuration from it net.sf.saxon.jaxp.IdentityTransformer.getConfiguration(), then create your own Saxon 9 transformer with that configuration changed in some way by you?

For example in the configuration for the XSLT transformer created by us you can find the net.sf.saxon.Configuration.getMessageEmitterClass() message emitter class which outputs to our messages view.

Regards,
Radu

Re: createXSLTTransformer with custom configuration

Posted: Thu May 21, 2015 6:22 pm
by Patrik
Hi Radu,

sounds like a great workaround. Will try that...

Thanks,
Patrik

Re: createXSLTTransformer with custom configuration

Posted: Tue May 26, 2015 11:51 am
by Patrik
Hi Radu,

I implemented it now the way you suggested and it works fine. :)

Thanks again,
Patrik

Re: createXSLTTransformer with custom configuration

Posted: Tue May 26, 2015 11:59 am
by Radu
Hi Patrik,

Great.
One thing you could do would be that when you call XMLUtilAccess.createXSLTTransformer() you could avoid passing it your main XSLT (which may be quite large) because processing power would be spent to compiled it and afterwards its compiled version would be used for nothing. So you could pass it a very small stylesheet, just because later you will reuse only the configuration from this original transformer.

Regards,
Radu

Re: createXSLTTransformer with custom configuration

Posted: Tue May 26, 2015 12:13 pm
by Patrik
Hi Radu,

that's what I already did. Furthermore I store the baseCondifuration in a static variable to get it only once:

Code: Select all

if (baseConfiguration == null) {
final String dummyXsl = "<xsl:transform xmlns:xsl=\"http://www.w3.org/1999/XSL/Transform\" version=\"1.0\"/>";
TransformerImpl temp = (TransformerImpl)authorAccess.getXMLUtilAccess().createXSLTTransformer(
new SAXSource(new org.xml.sax.InputSource(new StringReader(dummyXsl))),
null,
XMLUtilAccess.TRANSFORMER_SAXON_ENTERPRISE_EDITION,
false);
baseConfiguration = (EnterpriseConfiguration)temp.getConfiguration();
}
EnterpriseConfiguration configuration = baseConfiguration;

configuration.set...
[...]

TransformerFactoryImpl tf = new TransformerFactoryImpl(configuration);
t = tf.newTransformer(xslSrc);
Regards,
Patrik