是否有用于Java的基于Push/Non-blocking的XML分析器? [英] Is there a Push-based/Non-blocking XML Parser for Java?

查看:34
本文介绍了是否有用于Java的基于Push/Non-blocking的XML分析器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一个XML解析器,而不是从InputStream或InputSource解析,而是允许将文本块推入解析器.例如.我想要以下内容:

I'm looking for an XML parser that instead of parsing from an InputStream or InputSource will instead allow blocks of text to be pushed into the parser. E.g. I would like to have something like the following:

public class DataReceiver {
    private SAXParser parser = //...
    private DefaultHandler handler = //...

    /**
     * Called each time some data is received.
     */
    public void onDataReceived(byte[] data) {
        parser.push(data, handler);
    }
}

原因是我希望它可以与NIO网络库一起使用,而不必为支持阻塞InputStream的每个连接模型还原回线程.

The reason is that I would like something that will play nice with the NIO networking libraries rather than having to revert back to a thread per connection model required to support a blocking InputStream.

推荐答案

这是Xerces J-Users邮件列表中的一篇帖子(2009年4月),其中原始发帖人的问题完全相同.给出了杰夫"一个可能非常好的答复,但没有跟进原始发帖人的答复:

This is a (April 2009) post from the Xerces J-Users mailing list, where the original poster is having the exact same issue. One potentially very good response by "Jeff" is given, but there is no follow up to the original poster's response:

http://www.nabble.com/parsing-an-xml-document-chunk-by-chunk-td22945319.html

它可能很新,足以跻身榜单,或者至少对搜索有所帮助.

It's potentially new enough to bump on the list, or at very least help with the search.

修改

找到了另一个有用的链接,提到了一个名为Woodstox的库,并描述了Stream与基于NIO的解析器的状态以及一些模拟流的可能方法:

Found another useful link, mentioning a library called Woodstox and describing the state of Stream vs. NIO based parsers and some possible approaches to emulating a stream:

http://markmail.org/message/ogqqcj7dt3lwkbov

这篇关于是否有用于Java的基于Push/Non-blocking的XML分析器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆