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

 


Help: OASIS Mailing Lists Help | MarkMail Help

 


 

   Re: ModSAX (SAX 1.1) Proposal

[ Lists Home | Date Index | Thread Index ]
  • From: James Clark <jjc@jclark.com>
  • To: "'xml-dev@ic.ac.uk'" <xml-dev@ic.ac.uk>
  • Date: Fri, 19 Feb 1999 09:38:37 +0700

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@ic.ac.uk
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@ic.ac.uk the following message;
(un)subscribe xml-dev
To subscribe to the digests, mailto:majordomo@ic.ac.uk the following message;
subscribe xml-dev-digest
List coordinator, Henry Rzepa (mailto:rzepa@ic.ac.uk)





 

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

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