创建一个对于读取操作线程安全的 DOM
我的应用程序从多个 xml 源组成一个网页模型。这些源被正常的 Xerces 解析器解析为 DOM 对象到内存中。不幸的是,Xerces DOM 对象对于只读操作来说不是线程安全的。我希望能够重用解析后的 DOM 进行读取。有谁知道我使用的另一个解析器或一个简单的线程安全的读取 DOM 实现?
My application composes a webpage model from a number of xml sources. These sources are being parsed into memory as DOM objects with the normal Xerces parser. Unfortunately, Xerces DOM objects are not thread safe for read-only operations. I would like to be able to reuse the parsed DOM for read. Does anyone know of another parser or a simple thread safe for read DOM implementation that I use?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
Saxon 为其内部和不可变的数据结构提供 DOM 包装器。
(用 saxon-he 9.5.1 测试)
Saxon provides DOM wrappers to its internal and immutable data structure.
(tested with saxon-he 9.5.1)
我不知道有什么完美且简单的解决方案。
一个想法可能是使用线程安全对象重新创建 Dom。
在这种情况下,它们最好是不可变,因为您是只读的。
不可变性还为进一步改进提供了可能性(例如,实例共享,这将导致更小的内存占用)。
我希望我能建议一个可以做到这一点的库,因为它需要大量的编码......
I don't know any perfect and simple solution.
An idea might be to recreate the Dom using thread-safe objects.
In this case, they would preferably be immutable, as you are reading-only.
Being immutable also opens possibilities for further improvements (instance sharing for example, that would lead to smaller memory footprint).
I wish I could suggest a library that does this, as it is a fair amount of coding...