[XML-DEV Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

LMNL Pull


lmnl
Jeni Tennison scripsit:

> Can you expand on that? I must admit that I remain ignorant of
> pull-based XML event APIs. Is there are a good one around that we can
> adapt?

I know of two: XMLPULL (www.xmlpull.org) and the .NET XMLReader framework.

ERH has a nice writeup on XMLPULL at
http://www.xml.com/lpt/a/2002/08/14/xmlpull.html

He makes criticisms there that are IMO mostly well-rebutted by the
XMLPULL creators at:
http://www.xml.com/lpt/a/2002/09/25/xmlpull.html

I know less about the .NET stuff, but it seems to be basically very similar
but with a lot more bells, whistles, and gongs.  The official MS C#Doc is at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlReaderClassTopic.asp

The chief advantages of a pull API are two: it makes things easier for people
who are used to pulling content from files or databases (as opposed to
having GUI events pushed to them), and it makes the recursive-descent pattern
possible, in which the structure of the application mirrors the structure of
the document it is processing.  ERH's XHTML header example is clumsy because
it does not use this pattern properly, instead flattening it into
a classic C-style event loop.   The rebuttal article shows an improved version,
but it still isn't recursive descent, which would look something like this:

void parseHeader() {
      while (true) {
  	   int event = parser.next();
  	   if (event == XmlPullParser.START_TAG && isHeader(parser.getName())) {
               parseHeader();
  	   }
  	   else if (event == XmlPullParser.END_TAG && isHeader(parser.getName())) {
               System.out.println();
               return;
  	   }
  	   else if (event == XmlPullParser.TEXT) {
  	     System.out.print(parser.getText());
  	   }
  	   else if (event == XmlPullParser.END_DOCUMENT) return;

      }
    }
}

The possible nesting of header elements is managed by Java recursion.

-- 
All Gaul is divided into three parts: the part          John Cowan
that cooks with lard and goose fat, the part            www.ccil.org/~cowan
that cooks with olive oil, and the part that            www.reutershealth.com
cooks with butter. -- David Chessler                    jcowan@r...

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
 

Stylus Studio has published XML-DEV in RSS and ATOM formats, enabling users to easily subcribe to the list from their preferred news reader application.


Stylus Studio Sponsored Links are added links designed to provide related and additional information to the visitors of this website. they were not included by the author in the initial post. To view the content without the Sponsor Links please click here.

Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.