3

I m using SAX based XML parser, things are working fine but I'm getting the following warning message in log

com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl is Sun proprietary API and may be removed in a future release 
                                transformerFactory = new TransformerFactoryImpl();

I want to get rid of this, can anybody suggest me other options for TransformerFactoryImpl?

BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Chinmay
  • 180
  • 1
  • 2
  • 13

1 Answers1

4

You can use TransformerFactory.newInstance() instead:

javax.xml.transform.TransformerFactory tf =       
        javax.xml.transform.TransformerFactory.newInstance();

How it determines which implementation to load is told in Javadocs.

If it is important to keep care that you have exactly same implementation behind the scenes that you are currently using, just set following system property before obtaining TransformerFactory instance. I assume that using same implementation is convenient, as long as you get rid of error message.

System.setProperty("javax.xml.transform.TransformerFactory",          
                   "com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl");
BuZZ-dEE
  • 6,075
  • 12
  • 66
  • 96
Mikko Maunu
  • 41,366
  • 10
  • 132
  • 135
  • Hello @Mikko, I tried the javax.xml.transform.TransformerFactory initially but i was getting following exception.
    Can't transform a Source of type javax.xml.transform.stax.StAXSource :
    javax.xml.transform.TransformerException: Can't transform a Source of type javax.xml.transform.stax.StAXSource
     at org.apache.xalan.transformer.TransformerIdentityImpl.transform(TransformerIdentityImpl.java:366)
    
    

    I missed to set system property. Thanks for the help. Thanks a lot, Chinmay Pathak
    – Chinmay Jul 20 '12 at 07:35