Best practice to use multiple XML processors?
My project is using multiple implementations of XML processors (Java default, saxon 9, xerces 2). So, for x开发者_开发技巧ml processing I have to tell which class to load for DocumentBuilderFactory and XPathFactory etc.
We can do it in several ways as defined in Java docs. What is good practice for this:- Use Constructor as introduced in Java 6 (Project already has dependency on Java 6)?
- Use the javax.xml.parsers.DocumentBuilderFactory/XPathFactory system properties?
- Use the properties file "lib/jaxp.properties" in the JRE directory?
- Use the Services API?
I'd go with option 1 as it's the least "magic". As an aside, last I checked the "Java default" XML parser was just a broken version of xerces.
精彩评论