aspose file tools*
The moose likes XML and Related Technologies and the fly likes Default TransformerFactory Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Spring in Action this week in the Spring forum!
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Default TransformerFactory" Watch "Default TransformerFactory" New topic
Author

Default TransformerFactory

Greg Snyder
Greenhorn

Joined: Feb 09, 2010
Posts: 3
Hello, I am wondering what the default values for these properties are:

javax.xml.parsers.DocumentBuilderFactory
javax.xml.transform.TransformerFactory

We recently needed to do some work with an Oracle xml parser, but once it is on the classpath it takes over as the default, which I do not want to happen. We updated these properties to use Xerces:

javax.xml.parsers.DocumentBuilderFactory=org.apache.xerces.jaxp.DocumentBuilderFactoryImpl
javax.xml.transform.TransformerFactory=org.apache.xalan.processor.TransformerFactoryImpl

But now it is complaining about arguments we are passing to the transformer which used to work. What we want to do is just reset this property so that things go back to the way there were before we added the Oracle jar on the classpath (and not need to update any code). Ideas?

Thanks!
Greg Snyder
Greenhorn

Joined: Feb 09, 2010
Posts: 3
Also, the property that is failing is:


trans.setOutputProperty("{http://xml.apache.org/xslt}indent-amount", Integer.toString(this.indentLength))


Is there a better way to to this?
Brad Markel
Greenhorn

Joined: Mar 02, 2010
Posts: 5
In case you ever need this again, I found it with the following program (run this without the Oracle XDK JAR on the classpath)



The defaults are:


I had problems with Oracle's XDK too, so I know how frustrating this can be!

You have to put files in META-INF/services on the classpath that are specifically named like the factory interface names. For example, to override the DocumentBuilderFactory, you need a file called "javax.xml.parsers.DocumentBuilderFactory" and it has to have the text "com.sun.org.apache.xerces.internal.jaxp.DocumentBuilderFactoryImpl" in it (no spaces or newlines).

Keep in mind this is ONLY for Java 6 - Java 5 and 7 may be different. I kind of wish this were documented somewhere.

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Default TransformerFactory