[pyxb-users] generating xml documents from python instances
Brought to you by:
pabigot
From: victor <noa...@gm...> - 2010-10-05 23:20:45
|
hi list, i'm trying to generate an xml document from python instances but when i invoke the toxml() function, bunch of ns1s occur in the final string. so i created my module this way: python C:\lib\PyXB-1.1.2\scripts\pyxbgen -u file:pain.xsd -m pain then i did this in the interactive interface: >>> p = pain.Document() >>> p.CstmrDrctDbtInitn = pain.CustomerDirectDebitInitiationV02() >>> p.CstmrDrctDbtInitn.GrpHdr = pain.GroupHeader39() >>> p.CstmrDrctDbtInitn.GrpHdr.MsgId = pain.Max35Text('CAVAY1234') >>> p.toxml() Traceback (most recent call last): File "<stdin>", line 1, in <module> File "c:\lib\pyxb-1.1.2\pyxb\binding\basis.py", line 367, in toxml dom = self.toDOM(bds) File "c:\lib\pyxb-1.1.2\pyxb\binding\basis.py", line 353, in toDOM self._toDOM_csc(bds, element) File "c:\lib\pyxb-1.1.2\pyxb\binding\basis.py", line 2153, in _toDOM_csc eu.toDOM(dom_support, parent, v) File "c:\lib\pyxb-1.1.2\pyxb\binding\content.py", line 578, in toDOM value._toDOM_csc(dom_support, element) File "c:\lib\pyxb-1.1.2\pyxb\binding\basis.py", line 2144, in _toDOM_csc raise pyxb.DOMGenerationError('Binding value inconsistent with content model') pyxb.exceptions_.DOMGenerationError: Binding value inconsistent with content model but then i did >>> import pyxb >>> pyxb.RequireValidWhenGenerating(False) >>> p.toxml() and i get this u'<?xml version="1.0" ?><ns1:Document xmlns:ns1="urn:iso:std:iso:20022:tech:xsd:pain.008.001.02"><ns1:CstmrDrctDbtInitn><ns1:GrpHdr><ns1:Msg Id>CAVAY1234</ns1:MsgId></ns1:GrpHdr></ns1:CstmrDrctDbtInitn></ns1:Document>' any idea why i am getting those ns1? -- Victor |