cancel
Showing results for 
Search instead for 
Did you mean: 

Getting a TransformerHandler in Java Mappings

rosh
Participant
0 Kudos

Hello Experts,

I'm trying to get ajavax.xml.transform.sax.TransformerHandler in a java Messagemapping. The Transformerfactory if get from SAXTransformerFactory.newInstance() in the Mapping Runtime however is of the type com.sap.aii.ib.server.mapping.execution.jaxpfactories.MappingTransformerFactory which does not provide the newTransformerHandler() as javax.xml.transform.sax.SAXTransformerFactory.

I'm using PI 7.1. How can I get the TransformerHandler in a Java Mapping?

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi,

Have you checked this thread : ? Not sure you're facing the same, but could be worthing reading anyway

Chris

rosh
Participant
0 Kudos

Hi Christophe,

that dude has exactly my problem: SAP ships a custom TransformerFactory that does not offer the transformerhandler.

I dont want to switch to XSLT thogh

Answers (2)

Answers (2)

Former Member
0 Kudos

Hi all,

use

com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl

factory = new com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl();

instead of

SAXTransformerFactory factory =

(SAXTransformerFactory) SAXTransformerFactory.newInstance();

It should work fine.

Although class SAXTransformerFactory is designed to provide SAX-specific factory methods, it doesn't override newInstance() method (in fact there can be no overriding since this method is static, I mean defining the same method), that's why in fact it can return any TransformerFactory and you will get ClassCastException when try to cast to SAXTransformerFactory. Method newInstance() of class TransformerFactory at first looks for implementation class in system properties and then uses other ways in case of no success. If nothing is found, eventually class com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl is used.

I can assume that system property "javax.xml.transform.TransformerFactory" is set to "com.sap.aii.ib.server.mapping.execution.jaxpfactories.MappingTransformerFactory" by default during PI 7.1 installation. And class com.sap.aii.ib.server.mapping.execution.jaxpfactories.MappingTransformerFactory doesn't extend SAXTransformerFactory class.

Former Member
0 Kudos

Hi all,