XML.orgXML.org
FOCUS AREAS |XML-DEV |XML.org DAILY NEWSLINK |REGISTRY |RESOURCES |ABOUT
OASIS Mailing List ArchivesView the OASIS mailing list archive below
or browse/search using MarkMail.

 


Help: OASIS Mailing Lists Help | MarkMail Help

[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]
Re: [xml-dev] A new approach for SAX-Java Binding

Hi Santhosh,

Santhosh T <santhosh.tekuri@gmail.com> writes:

> http://code.google.com/p/jlibs/wiki/SAX2JavaBinding
> 
> this shows a new approach to define sax to java binding in very intutive
> manner.
> 
> your comments are welcomed;

This idea might be new to Java, though something like this has been 
available for C++ for several years now (see the C++/Parser[1] 
mapping, for example).

I also think in your architecture you miss one of the main reasons 
why people choose to use SAX over, say, DOM. Which is that they don't
want to (or cannot afford to) build an in-memory representation.
Instead, the XML data is processed as soon as it becomes available
in a pure event-driven or a partially in-memory / partially event-
driven mode. 

In this light, a callback interface like this seems like a more 
natural choice (using your Employee example):

public interface Employee {

  public void name (String name);
  public void age (int age);
  public void experience (int exp);
};

In the C++/Parser mapping I mentioned above this interface as well
as the "SAX routing code" are automatically generated from XML Schema.

The user can then implement this interface to receive the data:

public class EmployeeImpl implements Employee {

  public void name (String name)
  {
    // Handle name.
  }

  public void age (int age)
  {
    // Handle age.
  }

  public void experience (int exp)
  {
    // Handle experience.
  }
};


[1] http://www.codesynthesis.com/products/xsd/c++/parser/

Boris

-- 
Boris Kolpackov, Code Synthesis        http://codesynthesis.com/~boris/blog
Open-source XML data binding for C++   http://codesynthesis.com/products/xsd
XML data binding for embedded systems  http://codesynthesis.com/products/xsde
Command line interface to C++ compiler http://codesynthesis.com/projects/cli


[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index]


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

Copyright 1993-2007 XML.org. This site is hosted by OASIS