createXSLTTransformer with custom configuration

Post here questions and problems related to oXygen frameworks/document types.
Patrik
Posts: 228
Location: Hamburg/Germany

createXSLTTransformer with custom configuration

Thu May 21, 2015 1:57 pm

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: 5867

Re: createXSLTTransformer with custom configuration

Thu May 21, 2015 4:58 pm

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: 228
Location: Hamburg/Germany

Re: createXSLTTransformer with custom configuration

Thu May 21, 2015 6:22 pm

Hi Radu,

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

Thanks,
Patrik
Patrik
Posts: 228
Location: Hamburg/Germany

Re: createXSLTTransformer with custom configuration

Tue May 26, 2015 11:51 am

Hi Radu,

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

Thanks again,
Patrik
Radu
Posts: 5867

Re: createXSLTTransformer with custom configuration

Tue May 26, 2015 11:59 am

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: 228
Location: Hamburg/Germany

Re: createXSLTTransformer with custom configuration

Tue May 26, 2015 12:13 pm

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

Return to “SDK-API, Frameworks - Document Types”

Who is online

Users browsing this forum: No registered users and 0 guests