OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   LMNL Pull

[ Lists Home | Date Index | Thread Index ]

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@reutershealth.com




 

News | XML in Industry | Calendar | XML Registry
Marketplace | Resources | MyXML.org | Sponsors | Privacy Statement

Copyright 2001 XML.org. This site is hosted by OASIS