xerces java,Java 6中的xerces序列化

In Java 6, the entire xerces XML parser/serializer implementation is now in the Java runtime (rt.jar). The packages have been moved under the com.sun.* namespace, which places them off-limits for explicit reference within client code. This is not a problem when using the parser, which is instantiated via javax API-defined factories.

However, our code also uses xerces serialization (org.apache.xml.serialize.* ). AFAICT, there are no javax.xml API-defined factories for creating instances of Serializer and OutputFormat. This seems to imply that the only way to get one is to explicitly call the com.sun.org.apache.xml.serialize.* APIs.

I've found the serialization classes in javax.xml.stream, but they don't seem to provide any output-formatting control like the xerces OutputFormat class.

Question:

Is there a way to access the xerces serialization functionality (which is in rt.jar) via a javax standard API, without including xerces.jar and also without explicitly instantiating com.sun.* classes?

If not, is there an javax API-compliant way to achieve the same effect?

解决方案

If you want to use a Xerces feature that's not exposed through an official java.* or javax.* API, then your only real solution is to include Xerces as a third-party library. Accessing the JRE-internal version of Xerces in any way would be a dangerous thing, since nothing guarantees that a valid JRE even has those classes (alternate JREs and even other versions of the same JRE might implement the JAXP APIs using a different implementation or even just move it to another package).

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值