Meaningless Drivel is fun!
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
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Default TransformerFactory" Watch "Default TransformerFactory" New topic

Default TransformerFactory

Greg Snyder

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


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:


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?

Greg Snyder

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

trans.setOutputProperty("{}indent-amount", Integer.toString(this.indentLength))

Is there a better way to to this?
Brad Markel

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 "" 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:
subject: Default TransformerFactory
It's not a secret anymore!