加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 编程开发 > Java > 正文

java – JAXP XSLT document()函数问题

发布时间:2020-12-14 19:14:45 所属栏目:Java 来源:网络整理
导读:我在使用XSLT转换的java应用程序下工作.我有很多document()调用,所以有可能有java.lang.OutOfMemory异常(我实际上有),因为在每次调用document()函数之后,文档都会被缓存. 在http://xml.apache.org/xalan-j/faq.html#faq-N102F9我读到有可能 增加堆内存大小,

我在使用XSLT转换的java应用程序下工作.我有很多document()调用,所以有可能有java.lang.OutOfMemory异常(我实际上有),因为在每次调用document()函数之后,文档都会被缓存.

在http://xml.apache.org/xalan-j/faq.html#faq-N102F9我读到有可能
增加堆内存大小,这不是我的解决方案.我也尝试使用似乎不支持的增量变换.

那么,有没有可能在使用document()函数时关闭jaxp中的文档缓存?

最佳答案
与user1066037的答案一样,希望你可以切换到Saxon. Saxon有一个名为saxon的扩展名:discard-document.它可以在PE或EE版本或Saxon-B中使用.在这里搜索“Saxon-B”:http://saxon.sourceforge.net/

来自撒克逊文件:

saxon:discard-document()

saxon:discard-document($doc as document-node()) ==> document-node()

This function removes a document from Saxon’s internal document pool.
The document remains in memory for the time being,but will be
released from memory by the Java garbage collector when all references
to nodes in the document tree have gone out of scope. This has the
benefit of releasing memory,but the drawback is that if the same
document is loaded again during the same transformation,it will be
reparsed from the source text,and different node identifiers will be
allocated. The function returns the document node that was supplied as
an argument,allowing it to be used in a call such as
select=”saxon:discard-document(document(‘a.xml’))”.

如果您需要一个如何使用saxon的示例:discard-document,请告诉我,我可以发布一个.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读