You can view the issue detail at the following URL:
<http://scarab.werken.com/scarab/issues/id/TRQS79>

Type :        Feature
Issue Id :    TRQS79
Reported by: Gareth Boden
             tapina - ([EMAIL PROTECTED])

Details:

Summary: Retrieving objects as XML
Description: From the mailing list: 

Some time ago we had a little discussion about XML generation from 
Torque Objects. I've written some code to do this, using 
commons-betwixt, now. The way it works is that you add 
serialization="xml" to your <table> definitions, and the resulting 
Objects contain a toXml() method, and also implement 
java.io.Externalizable (in XML form). Most of the code is on BaseObject 
rather than generated into the separate Base Objects. FK-relationships 
are retained and you can override the interesting bits by overriding a 
method defined in the Base Object which performs the equivalent function 
of the ".betwixt" file. I haven't yet done the XML->Torque direction. No 
extra files are generated (all the betwixt config is done in code).

Here is the bzipped patch and two new source files which are also needed.

The changes to the DTD are attributes: defaultSerialization (database) 
and serialization (table) (java|xml, defaults to the existing Java 
serialization - BaseObject implements java.io.Serializable); and the 
attribute xmlElement (on a column) can be used to name an XML element 
explicitly (otherwise it uses the column name, with underscores removed 
and characters following underscores capitalised, remaining case 
unchanged).

The build obviously now also includes the betwixt jar.

BaseObject now includes a couple of protected methods, 
getXMLIntrospector() and toXml(), in case you wanted to override the 
default behaviour in some way. It also provides methods to implement the 
Externalizable API, but doesn't actually declare itself to implement 
Externalizable (that is done by the generated Object). Generated Objects 
which are Externalizable also have a getElementDescriptor method which 
is used by the BaseObject to configure betwixt to generate correct XML 
for that object.

Note that the externalizing is only one-way (out) at the moment. Using 
betwixt to construct data trees from XML is left as an short exercise 
for the reader ;-)




--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to