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

Re: SAX2: Handler Interfaces

  • From: "Ean R . Schuessler" <ean@n...>
  • To: xml-dev@x...
  • Date: Thu, 16 Mar 2000 21:03:20 -0600

xml sax2
Not that I agree with this arguement, but you could almost carry this to the
point of just making all the Handlers a type of Property. Then you could get
and set them by their URIs. Again, not that I advocate that necessarily.

On Wed, Mar 15, 2000 at 10:30:54AM -0800, Box, Don wrote:
> I don't think I made myself clear. I wasn't advocating a change to any of
> the XXXHandler interfaces nor to DefaultHandler. Rather, I was questioning
> why XMLReader needs a separate "setter" for both ContentHandler and
> LexicalHandler (and arguably DTDHandler and EntityResolver). The only reason
> to use separate "setters" is to allow someone to use a separate object per
> interface. However, it is hard to imagine someone calling setLexicalHandler
> without also calling setContentHandler. Similar (but somewhat less
> compelling) arguments could be made for DTDHandler and EntityResolver.
> 
> Imagine an implementation of XMLReader that looked like this:
> 
> class MyReader implements XMLReader {
>   ContentHandler ch;
>   DTDHandler     dh;
>   EntityResolver er;
>   LexicalHandler lh;
> 
>   public void setHandler(ContentHandler h) {
>     dh = null;
>     er = null;
>     lh = null;
>     ch = h;
>     if (h instanceof DTDHandler)
>       dh = (DTDHandler)h;
>     if (h instanceof LexicalHandler)
>       lh = (LexicalHandler)h;
>     if (h instanceof EntityResolver)
>       er = (EntityResolver)h;
>   }
> }
> 
> If you don't like the casts (which are a cornerstone of interface-based
> programming in Java, COM and CORBA), one could add a specific "getter"
> method to content handler:
> 
>   public abstract Object getHandler(String interfaceName);
> 
> which would change the method above to look like this:
> 
>   public void setHandler(ContentHandler h) {
>     ch = h;
>     dh = (DTDHandler)h.getHandler("org.xml.sax.DTDHandler");
>     lh = (LexicalHandler)h.getHandler("org.xml.sax.LexicalHandler");
>     er = (EntityResolver)h.getHandler("org.xml.sax.EntityResolver");
>   }
> 
> One of my main motivations for proposing this change is that I would like to
> see the role of XMLReader reduced. Ideally, passing around a ContentHandler
> reference should allow me to have sufficient information to "transmit" an
> entire XML Document. The way SAX2 sits now, I must pass around an XMLReader
> in order to give you a way to "discover" the four required interfaces. THis
> also means I'm passing around an object reference with methods like
> "setXXXHandler" and "parse", neither of which make sence. 
> 
> In summary, my request is that we refactor in order to have a single object
> reference from which I can discover all four handler/resolver interfaces. 

-- 
__________________________________________________________________
Ean Schuessler                                 A guy running Linux
Novare International Inc.                  A company running Linux
*** WARNING: This signature may contain jokes.

***************************************************************************
This is xml-dev, the mailing list for XML developers.
To unsubscribe, mailto:majordomo@x...&BODY=unsubscribe%20xml-dev
List archives are available at http://xml.org/archives/xml-dev/
***************************************************************************

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.