axis-java-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Leung" <twle...@sauria.com>
Subject Re: [Xerces2] Pull Parsing
Date Wed, 15 Aug 2001 05:08:51 GMT
Alek,

Glad to have your input and thoughts.
----- Original Message -----
From: "Aleksander Slominski" <aslom@cs.indiana.edu>
To: <axis-dev@xml.apache.org>
Cc: <xerces-j-dev@xml.apache.org>
Sent: Tuesday, August 14, 2001 9:52 AM
Subject: Re: [Xerces2] Pull Parsing


> hi,
>
> it is interesting coincidence that you write about it - i was planning to
> do the same to investigate how to provide alternative XPP2 implementation
> using Xerces2 XNI pull interface - i have separated API interfaces from
> implementation(s) by use of JAXP-like factory mechanism. and it would be
> really nice to have more than one implementation :-)
>
> ----- Original Message -----
> From: "Ted Leung" <twleung@sauria.com>
> To: <xerces-j-dev@xml.apache.org>
> Cc: <axis-dev@xml.apache.org>
> Sent: Tuesday, August 14, 2001 2:34 AM
> Subject: Re: [Xerces2] Pull Parsing
>
>
> > I've looked at XPP and KXML as alternative pull parsers.
> >
> > XPP returns an int based typecode and then you get to call one of
> > a number of methods and supply a data struture to be filled in.  It's
> very
> > C like, and because of that, it's likely to be efficient in nice ways.
> >
>
> please take a look on XPP2 which is a major API revision of XPP.
> when you mention this tradeoff you may be interested to find out that
> i had the same problem and even come up with nice solution which is
> very OO but it does not add much value to API (and in my opinion
> adding extra class to represent event is complicating API and making
> jar file bigger...).

I think that we have slightly different design centers for the API.  From
reading
your pages and your comments, It seems to me that you are focused on
small jar size and minimum API.  Is this accurate?

I'm interested in pull parsing as a replacement API for SAX and DOM.  DOM
is too bloated, and SAX is not very intuitive for most people.  So I'm
leaning
towards something like your XMLPullParserEvent.  It involves object like
behavior,
which is something that DOM people like, but it won't be as bloated as DOM,
which everybody will like.   The one thing I still don't like is the object
creation, so
perhaps it would be better to make XMLPullParserEvent an interface, and have
the user pass in an a object that would be filled in by the parser.

> below is XmlPullParserEvent class that could be returned for pp.next()
> instead of byte (notice that user code won't change much if it is byte of
> XmlPullParserEvent) for typical usage:
>
>     XmlPullParser pp = factory.newPullParser();
>     pp.setInput(new Reader(...));
>     //XmlPullParserEvent  eventType; //using new approach
>     byte  eventType; //and current style
>     eventType = pp.next();
>     if(eventType == XmlPullParser.CONTENT) ...
>
> thanks,
>
> alek
> ps. here is how XmlPullParserEvent could look (notice that state is
> modeled as singletons):
>
> /**
>  * Utility class to nicely describe the state of XML Pull Parser.
>  *
>  * @author Aleksander Slominski [aslom@extreme.indiana.edu]
>  */
> public class XmlPullParserEvent {
>
>  /** parsing is finished - we are at the end of input */
>  public static final XmlPullParserEvent END_DOCUMENT =
>   new XmlPullParserEvent("END_DOCUMENT");
>
>  /** start tag was just read */
>  public static final XmlPullParserEvent START_TAG =
>   new XmlPullParserEvent("START_TAG");
>
>  /** end tag was just read */
>  public static final XmlPullParserEvent END_TAG =
>   new XmlPullParserEvent("END_TAG");
>
>  /** element content was just read */
>  public static final XmlPullParserEvent CONTENT =
>   new XmlPullParserEvent("CONTENT");
>
>  protected XmlPullParserEvent(String name) {
>   this.name = name;
>  }
>
>  //TODO equals, hashCode
>
>  public final String toString() {
>   return name;
>  }
>
>  public static XmlPullParserEvent parse(String name) {
>   XmlPullParserEvent xs = null;
>   if(END_DOCUMENT.name.equals(name)) return END_DOCUMENT;
>   if(START_TAG.name.equals(name)) return START_TAG;
>   if(END_TAG.name.equals(name)) return END_TAG;
>   if(CONTENT.name.equals(name)) return CONTENT;
>   if(xs == null) throw new IllegalArgumentException
>    ("unknown xml state: "+name);
>   return xs;
>  }
>
>  protected String name;
> }
>
>


Mime
View raw message