Re: [pyxb-users] generating xml documents from python instances
Brought to you by:
pabigot
|
From: Peter B. <bi...@ac...> - 2010-10-06 00:53:54
|
The ns1 annotations occur because your schema specifies that the elements are in the urn:iso:std:iso:20022:tech:xsd:pain.008.001.02 namespace. See http://pyxb.sourceforge.net/userref_usebind.html#creating-xml-documents-from-binding-instancesfor information on how to control the namespace qualifiers. Search the provided examples or the mailing list archive for ways to set the default namespace when generating documents, which would eliminate the qualifiers on most elements and attributes. FWIW, the namespace qualifiers are required to produce valid XML, and are unrelated to whether your document validates. Peter On Tue, Oct 5, 2010 at 6:20 PM, victor <noa...@gm...> wrote: > 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 > > > ------------------------------------------------------------------------------ > Beautiful is writing same markup. Internet Explorer 9 supports > standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. > Spend less time writing and rewriting code and more time creating great > experiences on the web. Be a part of the beta today. > http://p.sf.net/sfu/beautyoftheweb > _______________________________________________ > pyxb-users mailing list > pyx...@li... > https://lists.sourceforge.net/lists/listinfo/pyxb-users > |