[XML-SIG] Standard methods for turning and object into an xml document.

Rich Salz rsalz@zolera.com
Thu, 13 Dec 2001 13:08:22 -0500


ZSI comes close:
class Foo: pass
class Bar: pass

af = Foo()
af.z = "z attr"
af.x = 12
af.quux = (1,2,"34", u'skiddoo')

from ZSI import *
import sys
sw = SoapWriter(sys.stdout, envelope=0)
sw.serialize(af, TC.Any("your-name-here"))

print '- ' * 30
bf = Bar()
bf.my_a = af
bf.more = 'less'
bf.d = { 'k1': 'v1' }
sw.serialize(bf, TC.Any("your-other-name-here"))

gets you this.  It's close; finding the errors is left as an exercise.
:)

<your-name-here>
<xsd:string id="810c870">z attr</xsd:string>
<x xsi:type="xsd:integer">12</x>
<quux SOAP-ENC:arrayType="xsd:anyType[4]">
<E80cb0f8 xsi:type="xsd:integer">1</E80cb0f8>
<E80cb0e0 xsi:type="xsd:integer">2</E80cb0e0>
<xsd:string id="810ca70">34</xsd:string>
<xsd:string id="810cab8">skiddoo</xsd:string>
</quux>
</your-name-here>
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 
<your-other-name-here>
<xsd:string id="810d378">less</xsd:string>
<d>
<xsd:string id="810d408">v1</xsd:string>
</d>
<my_a>
<xsd:string href="#810c870"/>
<x xsi:type="xsd:integer">12</x>
<quux SOAP-ENC:arrayType="xsd:anyType[4]">
<E80cb0f8 xsi:type="xsd:integer">1</E80cb0f8>
<E80cb0e0 xsi:type="xsd:integer">2</E80cb0e0>
<xsd:string href="#810ca70"/>
<xsd:string href="#810cab8"/>
</quux>
</my_a>
</your-other-name-here>

-- 
Zolera Systems, Your Key to Online Integrity
Securing Web services: XML, SOAP, Dig-sig, Encryption
http://www.zolera.com