开发者

Best practice to use multiple XML processors?

开发者 https://www.devze.com 2023-01-29 09:10 出处:网络
My project is usingmultiple 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

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:

  1. Use Constructor as introduced in Java 6 (Project already has dependency on Java 6)?
  2. Use the javax.xml.parsers.DocumentBuilderFactory/XPathFactory system properties?
  3. Use the properties file "lib/jaxp.properties" in the JRE directory?
  4. 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消