[XML-SIG] Guidance sought

Richard Wall dick.wall@bigfoot.com
Wed, 03 May 2000 09:21:44 -0400


Hello all,

I know that this is partially my own doing, but I have not had cause
to really get into XML in python up until now. Suddenly I find myself
with a need to do it, and everything I know about python tells me it
ought to be the natural choice with XML.

However I am finding the information about the 5 or 6 different
approached to XML confusing in finding a place to start. Probably the
easiest thing is to describe what I am trying to do, and maybe you
guys can point me in the right direction of what to learn.

We have an XML java interface that we use at my company to publish and
subscribe data from one of our systems. The output is created directly
from the contents of Java objects, and represents exactly the
structure of the object model in Java. All objects in this data are
wholly contained within parent objects, that is to say that there are
no references to other objects to deal with.

The basic objects are things like Case and Account, and these have
Attributes like Name and value and the like.

An example output from a simple class might look something like this:


- <com.ne.neo.pubsubs.descriptor.PsDescriptor> 
<Name type="java.lang.String">Allowance For Funds Used During
Construction</Name> 
<Type type="java.lang.String">Account</Type> 
<Version type="java.lang.String">1.1</Version> 
- <Data type="java.util.Hashtable"> 
<key type="java.lang.String">_AccountCategory</key> 
<value type="java.lang.String">AFUDC</value> 
<key type="java.lang.String">value</key> 
- <value type="com.ne.neo.pubsubs.descriptor.PsDescriptor"> 
<Name type="java.lang.String">value</Name> 
<Type type="java.lang.String">ImpactDDItem</Type> 
<Version type="java.lang.String">1.1</Version> 
- <Data type="java.util.Hashtable"> 
<key type="java.lang.String">Inputs</key> 
<value type="java.util.Hashtable" /> 
</Data> 
</value> 
<key type="java.lang.String">_AccountType</key> 
<value type="java.lang.Integer">1</value> 
<key type="java.lang.String">Label</key> 
<value type="java.lang.String">Allowance For Funds Used During
Construction</value> 
</Data> 
</com.ne.neo.pubsubs.descriptor.PsDescriptor> 


I have been able to get the whole thing loaded in to python very
easily using the DOM xml stuff (it was very easy actually) but I have
a feeling that writing my own document handler would be a better way
to do this. there are a high number of different Classes in the system
and I want to make classes responsible for their own xml importing and
exporting, having them recognize and fish out attributes for
themselves, and create child objects as necessary to handle embedded
objects in the XML.

Is this the right approach, and if so are there any tutorials covering
this. The majority of stuff I have seen so far tends to deal with
batch processing of XML with python, and what I reall want to do in
this case is to import this XML document directly into an equivalent
python object model to the java one from which it came. I understand
that I will have to convert Java types to python, but that should be
pretty easy (java.util.Hashtables to dictionaries, java.lang.String to
string). In fact I am thinking that for the hashtable in this case,
the __dict__ for the class can be set directly (so that the attribute
key/value pairs simply become python attributes).

Any pointers would be greatly appreciated, even if it is of the form
of "It's right here in this tutorial, moron!".

Thanks

Dick

-- 
dick.wall@bigfoot.com - Home
dwall@newenergyassoc.com - Work
QuaintRcky - AIM