xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Qwerty Poiu" <qwertypo...@hotmail.com>
Subject Re: Using XML to create Java objects
Date Thu, 31 Oct 2002 12:28:46 GMT
<html><div style='background-color:'><DIV>
<P>Hey Matt and all,</P>
<P>I think a xml to object mapper that doesn't need any config filoes like Digester
is worthwile, and I would love to try it out.&nbsp; I like Digester and JAXB, JAXme, etc,
but I still think these are not the end of the story.<BR>I want to use such an engine
in conjuction with a few Schema and transformation languages to create forms in java and HTML,
but what I really&nbsp;am interested in is the Design Patterns behind all this, and considering
as many points of view as possible is really boradening my horizons.<BR></P>
<P>Tim C.</P></DIV>
<DIV></DIV>
<DIV></DIV>&gt;From: Matt Pickering <MP_SK8R@YAHOO.COM>
<DIV></DIV>&gt;Reply-To: general@xml.apache.org 
<DIV></DIV>&gt;To: general@xml.apache.org 
<DIV></DIV>&gt;Subject: Using XML to create Java objects 
<DIV></DIV>&gt;Date: Tue, 29 Oct 2002 21:37:19 -0800 (PST) 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Hello all, 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I use XML on a daily basis in my day job and recently 
<DIV></DIV>&gt;I've started work on some gaming projects that use XML 
<DIV></DIV>&gt;to store configuration and game data. One of the most 
<DIV></DIV>&gt;tedious tasks I've had to deal with in both realms is 
<DIV></DIV>&gt;the parsing of XML in order to create Java objects, 
<DIV></DIV>&gt;both simple and complex. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I know libraries and tools exist to do this, but they 
<DIV></DIV>&gt;all have one major drawback: they require me to write 
<DIV></DIV>&gt;code to describe the objects I want to create and map 
<DIV></DIV>&gt;the XML to them. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I've written an engine that allows me to express 
<DIV></DIV>&gt;simple and composite Java objects as XML and have Java 
<DIV></DIV>&gt;objects come out without any work on my part other 
<DIV></DIV>&gt;than providing a listener to capture the objects as 
<DIV></DIV>&gt;they are created. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The engine uses Java Reflection to construct objects 
<DIV></DIV>&gt;and call methods. Methods can accept simple 
<DIV></DIV>&gt;parameters or other objects, which can also be 
<DIV></DIV>&gt;expressed as nested XML. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The XML markup has to follow a few simple rules and a 
<DIV></DIV>&gt;mechanism is provided to allow the user to define 
<DIV></DIV>&gt;constants that can substitute one value for another as 
<DIV></DIV>&gt;well as define the tags that map to various objects. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Here is a simple example of some XML markup that 
<DIV></DIV>&gt;creates a Java Properties object: 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;<PROPERTIES> 
<DIV></DIV>&gt; <?xml:namespace prefix = twgp /><twgp:alchemy DIV
<>&gt;xmlns:twgp="http://www.wargameproject.org/transmuteml"&gt; 
<DIV></DIV>&gt; <twgp:mapping DIV < tag="myprops" parentTag="*">&gt;class="java.util.Properties"/&gt;

<DIV></DIV>&gt; </twgp:alchemy>
<DIV></DIV>&gt; <MYPROPS>
<DIV></DIV>&gt; <property value="value1" key="prop1"></property>
<DIV></DIV>&gt; <property value="value2" key="prop2"></property>
<DIV></DIV>&gt; <!-- Since Properties is a subclass of
</DIV>>Hashtable, the following shows
</DIV>>         we can also call put() instead of
</DIV>>setProperty(). -->
<DIV></DIV>&gt; <put value="value3" key="prop3"></put>
<DIV></DIV>&gt; </MYPROPS>
<DIV></DIV>&gt;</PROPERTIES> 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I've been using this engine to built game 
<DIV></DIV>&gt;configuration files as well as to build config files 
<DIV></DIV>&gt;for some rules-based code I use in my day job. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;My question to the list is this: Would there be any 
<DIV></DIV>&gt;interest to the community at large in such an engine? 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;I was planning to release the engine along with the 
<DIV></DIV>&gt;gaming code, but it is being maintained as a separate 
<DIV></DIV>&gt;codebase. I am willing to break the engine out and 
<DIV></DIV>&gt;maintain it as a separate project if there is 
<DIV></DIV>&gt;sufficient interest. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;The engine is general purpose but is scoped for 
<DIV></DIV>&gt;applications that use XML as configuration data but 
<DIV></DIV>&gt;don't want the hassle of having to parse the XML to 
<DIV></DIV>&gt;suit differing requirements. It is not a 
<DIV></DIV>&gt;serialization mechanism (although I plan to add a 
<DIV></DIV>&gt;converter to take instantiated objects and dump out 
<DIV></DIV>&gt;compatible XML markup). It certainly isn't a "be-all, 
<DIV></DIV>&gt;end-all" solution to the problem of XML-Java 
<DIV></DIV>&gt;conversion, but can address a decent amount of the 
<DIV></DIV>&gt;problems that an average developer may face in using 
<DIV></DIV>&gt;XML and Java. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;If anyone would like to know more, please reply to the 
<DIV></DIV>&gt;list or me directly. If this ins't the appropriate 
<DIV></DIV>&gt;forum for this, I do apologize and I will repost this 
<DIV></DIV>&gt;to the Jakarta list and take my chances there. 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;Matt Pickering 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;__________________________________________________ 
<DIV></DIV>&gt;Do you Yahoo!? 
<DIV></DIV>&gt;HotJobs - Search new jobs daily now 
<DIV></DIV>&gt;http://hotjobs.yahoo.com/ 
<DIV></DIV>&gt; 
<DIV></DIV>&gt;---------------------------------------------------------------------

<DIV></DIV>&gt;In case of troubles, e-mail: webmaster@xml.apache.org 
<DIV></DIV>&gt;To unsubscribe, e-mail: general-unsubscribe@xml.apache.org

<DIV></DIV>&gt;For additional commands, e-mail: general-help@xml.apache.org

<DIV></DIV></twgp:mapping></div><br clear=all><hr>Unlimited
Internet access for only $21.95/month.  Try MSN! <a href="http://g.msn.com/8HMREN/2019">Click
Here</a> </html>

---------------------------------------------------------------------
In case of troubles, e-mail:     webmaster@xml.apache.org
To unsubscribe, e-mail:          general-unsubscribe@xml.apache.org
For additional commands, e-mail: general-help@xml.apache.org


Mime
View raw message