xml-general mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Russell White <russw...@yahoo.com>
Subject Re: Using XML to create Java objects
Date Thu, 31 Oct 2002 12:47:56 GMT
All of you intersted in using XML object mapping as well UI building with XML
may be interested in the Swang project.

http://swang.sourceforge.net
or
http://sourceforge.net/projects/swang

Swang is reflective, and very powerful. It provides a plugguble modular
TagHandler mechanism, and a very flexible schema. One example of the modularity
of Swang is that the popular BeanShell scripting language is included as a
TagHandler in the distribution. The beans shell script has access to the
objects created with Swang, and vice versa. The means that you can use natural
Java notation, and complex expressions.

My comany uses Swang to provided rich UIs to applications that used to be just
HTML. Now thanks to JSP and XSL, we can provide any Java based UI along with
the HTML version.

Swang also takes some of the worry out of handling things like threads, and
thread safe changing of object properties by allowing you to mark methods to be
invoked using SwingUitilities.invokeLater() just by setting the attribute
'later' to true.

Check it out. I am really looking for advice on future versions, and am looking
to other projects for synergy and community effort. 


Forgive me that the example is not very full of features, but it does give a
good idea of the power. Also there is some documentation, certainly enough to
get started, but I am working on making it much better. The source code is not
large, and pretty simple to follow.

WR

Russ White
--- Qwerty Poiu <qwertypoi75@hotmail.com> wrote:

<HR>
<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



__________________________________________________
Do you Yahoo!?
HotJobs - Search new jobs daily now
http://hotjobs.yahoo.com/

---------------------------------------------------------------------
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