createXSLTTransformer with custom configuration

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

createXSLTTransformer with custom configuration

Post 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
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: createXSLTTransformer with custom configuration

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: createXSLTTransformer with custom configuration

Post by Patrik »

Hi Radu,

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

Thanks,
Patrik
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: createXSLTTransformer with custom configuration

Post by Patrik »

Hi Radu,

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

Thanks again,
Patrik
Radu
Posts: 9051
Joined: Fri Jul 09, 2004 5:18 pm

Re: createXSLTTransformer with custom configuration

Post 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
Radu Coravu
<oXygen/> XML Editor
http://www.oxygenxml.com
Patrik
Posts: 280
Joined: Thu Nov 28, 2013 9:32 am
Location: Hamburg/Germany
Contact:

Re: createXSLTTransformer with custom configuration

Post 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
Post Reply