Home > Articles > Web Services > XML

  • Print
  • + Share This
From the author of

Working with StAX

Now let’ look at StAX, an API that has been getting a lot of attention lately, especially in the performance-driven server and handheld device world. Like SAX, StAX is a streaming parser that’s useful when an application has strict memory limitations.

The big difference between SAX and StAX is that StAX uses pull parsing whereas SAX uses push parsing. While the push/pull distinction may not sound like much, pull parsing means that the application is in control of parsing activity and can call parser methods as needed. In contrast, push processing (SAX) has the parser in control of the application thread, which means that the client code invocation is under parser control. For cell phones that have limited processing power, the pull parsing of StAX is very attractive.

Here are some of the other advantages of the StAX pull model over the push model:

  • Pull parsing libraries are typically much smaller than push parsing libraries. Client code that interacts with pull libraries tends to be much simpler, even for more complex documents.
  • Pull clients are capable of reading multiple documents within a single thread.
  • A StAX pull parser can filter XML documents so that elements extraneous to the client can be ignored.
  • + Share This
  • 🔖 Save To Your Account