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

RFC: Simple XML Event-Based API for Java

  • From: David Megginson <ak117@f...>
  • To: xml-dev Mailing List <xml-dev@i...>
  • Date: Tue, 16 Dec 1997 21:38:51 -0500

java xml event
After careful thought, I am fairly certain that I would be willing to
accept the following simple event-driven API for Ælfred.  It meets
most of Tim Bray's concerns (I'd love to hear from Norbert Mikula and
from Chris Lovett), and it requires me to use only one extra class
file (the new XmlProcessor interface -- see below):


XmlApplication.java:
====================8<====================8<====================
import java.net.URL;
import java.util.Dictionary;

public interface XmlApplication {

  public void 
    startDocument (XmlProcessor processor, String pubid, URL sysid);

  public void 
    endDocument (XmlProcessor processor);

  public void
    startProlog (XmlProcessor processor);

  public void 
    endProlog (XmlProcessor processor);

  public void 
    startElement (XmlProcessor processor, String elname, 
                  Dictionary attributes);

  public void 
    endElement (XmlProcessor processor, String elname);

  public void 
    characters (XmlProcessor processor, char ch[], int start, int length);

  public void 
    processingInstruction (XmlProcessor processor, String target, String data);

  public void 
    error (XmlProcessor processor, String message, URL url, int line);
}

// end of XmlApplication.java
====================8<====================8<====================


The processor itself could implement the following interface (very
Thread-oriented and Bean-like):


XmlProcessor.java:
====================8<====================8<====================
import java.lang.Runnable;
import java.net.URL;

public interface XmlProcessor extends Runnable {

  public void setPublicId (String publicId);
  public String getPublicId ();

  public void setSystemId (URL systemId);
  public URL getSystemId ();

  public void setUserData (Object data);
  public Object getUserData ();

  public void addApplication (XmlApplication application);
  public void removeApplication (XmlApplication application);

  public void run();

}

// end of XmlProcessor.java
====================8<====================8<====================


I would lose Ælfred's resolveEntity() callback, the isSpecified
boolean for attributes and the simple String argument for character
data.  Tim would lose the ability to return a boolean to stop the
parse (the user would have to throw an exception), and would have to
rename more of his callbacks.

On the positive side, this interface would let you hang more than one
application off the same parse, which could be very interesting.  The
userData property also gives users a chance to pass extra information
to the processor easily, if they wish.

This new XmlProcessor interface (actually a parser, but I'm using the
XML spec's terminology here) does not preclude additional
functionality -- I'll keep all of Ælfred's DTD-query methods -- but
neither does it standardise that functionality.


All the best,


David

-- 
David Megginson                 ak117@f...
Microstar Software Ltd.         dmeggins@m...
      http://home.sprynet.com/sprynet/dmeggins/

xml-dev: A list for W3C XML Developers. To post, mailto:xml-dev@i...
Archived as: http://www.lists.ic.ac.uk/hypermail/xml-dev/
To (un)subscribe, mailto:majordomo@i... the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@i... the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@i...)


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.