|PULL PARSING VERSUS PUSH PARSING||89|
Pull Parsing Versus Push Parsing
Streaming pull parsing refers to a programming model in which a client applica-tion calls methods on an XML parsing library when it needs to interact with an XML infoset—that is, the client only gets (pulls) XML data when it explicitly asks for it.
• Pull clients can read multiple documents at one time with a single thread.
• A StAX pull parser can filter XML documents such that elements unnec-essary to the client can be ignored, and it can support XML views of non-XML data.
• Marshalling an XML document
• Parallel document processing
|90||STREAMING API FOR XML|
• Parsing WSDL
• Virtual data sources
• Pipelined XML processing
A complete discussion of all these use cases is beyond the scope of this chapter. Please refer to the StAX specification for further information.
• StAX is a bidirectional API, meaning that it can both read and write XML documents. SAX is read only, so another API is needed if you want to write XML documents.
• SAX is a push API, whereas StAX is pull. The trade-offs between push and pull APIs outlined above apply here.