Search code examples
jakarta-eexml-parsingsaxsaxparserxalan

Looking options for xalan TransformerFactoryImpl


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?


Solution

  • 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");