Assuming that pyxb generate are stored in a module called mybindings, I am doing the following:
>>> elem = mybinding.EarlyTerminationProvision()
>>> elem.optionalEarlyTerminationParameters = 'Foo'
>>> elem.optionalEarlyTermination = 'Bar'
>>> elem.toxml( element_name='earlyTermination' )
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "ext2\noarch\pylib\site-packages\pyxb\binding\basis.py", line 541, in toxml
File "ext2\noarch\pylib\site-packages\pyxb\binding\basis.py", line 513, in toDOM
File "ext2\noarch\pylib\site-packages\pyxb\binding\basis.py", line 2647, in _toDOM_csc
File "ext2\noarch\pylib\site-packages\pyxb\binding\basis.py", line 2174, in _validatedChildren
File "ext2\noarch\pylib\site-packages\pyxb\binding\content.py", line 640, in sequencedChildren
UnprocessedElementContentError: (<mybindings.EarlyTerminationProvision object at 0x2FE87450>, <pyxb.utils.fac.Configuration object at 0x2FE87510>, [<pyxb.binding.basis.ElementContent object at 0x2FE87E70>], {<pyxb.binding.content.ElementDeclaration object at 0x2FEBBD10>: [<pyxb.binding.datatypes.anyType object at 0x2FE87110>]})
>>> try:
... elem.toxml( element_name='earlyTermination' )
... except Exception as e:
... print e.details()
...
The containing element type EarlyTerminationProvision is defined at <unknown>[3:4]
The EarlyTerminationProvision automaton is in an accepting state.
The last accepted content was optionalEarlyTermination
No elements or wildcards would be accepted at this point.
The following content was not processed by the automaton:
optionalEarlyTerminationParameters (1 instances)
I presume this issue is linked to this statement in this document:
As of PyXB 1.2.0 the first legal transition in the order imposed by the schema is taken, and there is no provision for influencing the order in the generated document when multiple orderings are valid.
Is there a work around for this issue?
Regards
Arindam
Last edit: Arindam Roy 2016-11-02
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
The command I gave specifies that the orderedContent order is to be used. I suspect that creating the instance with keyword arguments puts the content in a different order. There is no solution for that other than changing the schema, or modifying the orderedContent array.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hello,
Given below is a simplified version of a schema I am using.
The design choice of the schema is admitted slightly unusual. Unfortunately I do not have powers to change the design.
Given the schema I am trying to generate a document like the below:
Assuming that pyxb generate are stored in a module called mybindings, I am doing the following:
I presume this issue is linked to this statement in this document:
Is there a work around for this issue?
Regards
Arindam
Last edit: Arindam Roy 2016-11-02
In fact, yes. Take a look at this description and this source file.
For your example, adding the following commands before generating the XML seems to make it work:
That works indeed. Many thanks, much appretiate the help!!!
The command I gave specifies that the orderedContent order is to be used. I suspect that creating the instance with keyword arguments puts the content in a different order. There is no solution for that other than changing the schema, or modifying the orderedContent array.