• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default TransformerFactory

 
Greg Snyder
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic