JAXP XSLT document() 函数问题
我正在使用 XSLT 转换的 java 应用程序下工作。我其中有很多 document() 调用,因此可能会出现 java.lang.OutOfMemory 异常(我实际上有),因为每次调用 document() 函数后,文档都会被缓存。
在 http://xml.apache.org/xalan-j/faq。 html#faq-N102F9 我读到可以 增加堆内存大小,这不是我的情况的解决方案。我还尝试使用似乎不支持的增量变换。
那么,在使用 document() 函数时是否有可能关闭 jaxp 中的文档缓存?
I am working under java application which uses XSLT transformation. I have a lot of document() calls in it, so it is possible to have java.lang.OutOfMemory exception (which I actually have), because after each call of document() function the document is cached.
At http://xml.apache.org/xalan-j/faq.html#faq-N102F9 I read that it is possible to
increase heap memory size which is not the solution in my case. I also tried to use incremental transform which seems to be not supported.
So, is there any possibility to turn off document caching in jaxp while working with document() function?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
就像user1066037的回答一样,希望你可以切换到Saxon。 Saxon 有一个名为
saxon:discard-document
的扩展。它有 PE 版、EE 版或 Saxon-B 版本。在此处搜索“Saxon-B”: http://saxon.sourceforge.net/从 Saxon 文档中:
如果您需要如何使用
saxon:discard-document
的示例,请告诉我,我可以发布一个。Like user1066037's answer, hopefully you can switch to Saxon. Saxon has an extension called
saxon:discard-document
. It's available in either the PE or EE editions or Saxon-B. Search for "Saxon-B" here: http://saxon.sourceforge.net/From the Saxon documentation:
If you need an example of how to use
saxon:discard-document
, let me know and I can post one.您提供的链接包含一个使用自定义处理指令来禁用缓存的示例。您尝试过那里建议的解决方法吗?
The link you provided contains an example using a custom processing instruction to disable caching. Did you try the workaround suggested there?
如果你有选择的话。
只需将 Xalan 替换为 Saxon,一切都会变得更快,并且您可以显着减少内存消耗。
据我所知,Xalan会将文档加载到内存中,除非最新版本中发生了某些更改。
Saxon 有流模式: http://www.saxonica.com/documentation/ sourcedocs/streaming/streaming-templates.xml
希望有帮助。
If you have a choice.
Just swap Xalan with Saxon and everything will be much faster and you may cut the memory consumption significantly.
From what I know, Xalan will load document into the memory, unless something has been changed in the latest release.
Saxon have streaming mode: http://www.saxonica.com/documentation/sourcedocs/streaming/streaming-templates.xml
Hope that helps.