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

Re: SAX and stuff ...

  • From: Stefan Haustein <haustein@l...>
  • Date: Wed, 26 Jul 2000 11:04:36 +0200

christmans cargs
Michael Brennan wrote:
> 
> My more recent approach is to have an "addChild" method on what you are
> calling the ParserListener (which I called "ElementHandler" in my
> implementation). Then, I use a simple Hashtable (loaded from a Java
> Properties file) to map element names to a class that is loaded via
> reflection (just as Stefan Haustein noted in another post). The BaseHandler
> that is maintaining the stack of current ElementHandlers invokes "addChild"
> on the parent ElementHandler after instantiating a new ElementHandler.

BTW: In my most recent approach I got rid of the Hashtable by adding
a prefix to the element name and then use the reflection capabilities
for resolving the element name to a full classified class name. 
Advantage: I do just need to create the corresponding classes in the
right package(s), no more ugly registering startup code for tons of
elements. The following code is simplified to show the principle. 
Actually it can handle classes from more than one package. My next 
step is to link that to xml namespaces somehow....

  public synchronized Element createElement (String name) {

    try {
      Class elementClass = ClassLoader.getSystemClassLoader ()
        .loadClass ("de.unido.ai.infolayer.templates.TemplateElement_" +
name);
                
      Class [] ctype = {String.class};
      Object [] cargs = {name};
                
      return (TemplateElement) elementClass.getConstructor (ctype)
        .newInstance (cargs);
    }
    catch (Exception e) {
        throw new ChainedRuntimeException (e);
    }
}       

Best,

Stefan
-- 
Stefan Haustein             
Univ. Dortmund, FB 4, LS 8   tel: +49 231 755 2499
Baroper Str. 301             fax: +49 231 755 5105
D-44221 Dortmund (Germany)   www-ai.cs.uni-dortmund.de

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.