什么是“推动方法”和“拉动方法”来解析? [英] What is 'Push Approach' and 'Pull Approach' to parsing?

查看:155
本文介绍了什么是“推动方法”和“拉动方法”来解析?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


在推送解析方法下,推送解析器生成同步事件,因为文档是
解析的,并且这些事件可以由应用程序使用回调处理程序模型处理

Under the push parsing approach, a push parser generates synchronous events as a document is parsed, and these events can be processed by an application using a callback handler model

这是关于SAX 2.0的 Pro XML Development with Java 一书中给出的文字。

This is the text given in the book Pro XML Development with Java about SAX 2.0.

至于StAX,这本书说:

As for StAX, the book says:


在拉动方式下,使用解析器在应用程序
的控制下从XML文档中提取事件。

Under the pull approach, events are pulled from an XML document under the control of the application using the parser.

我想问一下,突出显示文本的含义是什么?一个适合初学者的答案是值得赞赏的:)

I want to ask, what is the meaning of the highlighted text ? An answer befitting a beginner is appreciated :)

推荐答案

基本上,推送就是解析器对某个处理程序说我有foo,用它做点什么。拉动是当处理程序对解析器说,给我下一个foo。

Basically, a push is when the parser says to some handler, "I have a foo, do something with it." A pull is when the handler says to the parser, "give me the next foo."

推送:

if (myChar == '(')
    handler.handleOpenParen(); // push the open paren to the handler

拉:

Token token = parser.next(); // pull the next token from the parser

这篇关于什么是“推动方法”和“拉动方法”来解析?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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