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

Re: ModSAX (SAX 1.1) Proposal

  • From: James Clark <jjc@j...>
  • To: "'xml-dev@i...'" <xml-dev@i...>
  • Date: Fri, 19 Feb 1999 09:38:37 +0700

Re: ModSAX (SAX 1.1) Proposal
I don't see the point of this.  It doesn't seem to buy me anything over
what I can already do using normal programming language features:

interface PingParser extends Parser {
  void setPingHandler(PingHandler handler);
}

interface PingHandler {
  void ping();
}

void registerPingHandler(Parser parser, PingHandler handler) {
  try {
    ((PingParser)parser).setPingHandler(handler);
  }
  catch (ClassCastException e) {
    // ...
  }
}

I can do the same thing in COM with QueryInterface, or in C++ with RTTI.

The ModHandler class seems particularily useless.  It just creates a
completely unnecessary dependency between handler classes and the SAX
package.  You could use Object just as well.

None of this seems to solve the real problem which is actually defining
the handlers that are  needed to provide the functionality missing from
SAX 1.0 (like the handlers for comments, namespaces etc that were in the
previous draft).

David Megginson wrote:
> 
> Ingargiola, Tito writes:
> 
>  > Why is interface ModHandler empty?  Presumably, (an implementation
>  > of) ModParser is going to need to call methods on its handlers as
>  > it goes about its business .  Will it somehow know that for
>  > ModHandlers which implement, say, namespace processing, that it
>  > should call a particular method (I won't even attempt to suggest
>  > what that method might be :-)?
> 
> Maybe it will help if I walk through a silly example.  Here's the
> interface:
> 
>   public interface PingHandler extends org.xml.sax.ModHandler
>   {
>     public abstract void ping ();
>   }
> 
> Here's how I register it with a ModParser:
> 
>   try {
>     parser.setHandler("com.megginson.handlers.ping", pingHandler;
>   } catch (SAXException e) {
>     System.err.println("Parser does not support Ping handlers");
>   }
> 
> Here's part of my PingParser class:
> 
>   private PingHandler pingHandler;
> 
>   public void setHandler (String handlerID, ModHandler handler)
>     throws SAXNotSupportedException
>   {
>     if (handlerID.equals("com.megginson.handlers.ping")) {
>       pingHandler = (PingHandler)handler;
>     } else {
>       throw new SAXNotSupportedException("Unknown handler type: "
>                                          + handlerID);
>     }
>   }
> 
> In other words, if the class recognises the handlerID, then it will
> know how to cast it; if it does not, then it should throw an
> exception.



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/ and on CD-ROM/ISBN 981-02-3594-1
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.