I am trying to generate XML file using PYXB library. THe order in which the elements are generated is not same as The orderI am adding them. It is not same even after multiple generations.
Can anyone please suggest how to preserve the order.
Thanks in advance.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
It may be that the order you are adding them is not consistent with the order required by the schema, or the schema does not require a specific order, or you may be using mixed content. See this section of the manual and the use of pyxb.ValidationConfig (pabigot.github.io).
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi Peter Thank you for the reply.
How do I identify that its a mixed content?
Also, I used the following commnds
pyxb.ValidationConfig()._setContentInfluencesGeneration(pyxb.ValidationConfig.NEVER)
pyxb.binding.basis._TypeBinding_mixin()._setValidationConfig(pyxb.ValidationConfig.NEVER)
I still could not preseve the order. Can you please help me to which method I should use.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
There's not enough detail on what you're doing. If you open an issue on github that reproduces the problem with a simple schema I may be able to assist. However, unless the documents generated by PyXB violate the schema, changes to order of element and content is not a bug: order can only be preserved if order is enforced by the schema.
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi All,
I am trying to generate XML file using PYXB library. THe order in which the elements are generated is not same as The orderI am adding them. It is not same even after multiple generations.
Can anyone please suggest how to preserve the order.
Thanks in advance.
It may be that the order you are adding them is not consistent with the order required by the schema, or the schema does not require a specific order, or you may be using mixed content. See this section of the manual and the use of pyxb.ValidationConfig (pabigot.github.io).
Hi Peter Thank you for the reply.
How do I identify that its a mixed content?
Also, I used the following commnds
pyxb.ValidationConfig()._setContentInfluencesGeneration(pyxb.ValidationConfig.NEVER)
pyxb.binding.basis._TypeBinding_mixin()._setValidationConfig(pyxb.ValidationConfig.NEVER)
I still could not preseve the order. Can you please help me to which method I should use.
I set the following values and tried to generate. It still does not preserve the order
There's not enough detail on what you're doing. If you open an issue on github that reproduces the problem with a simple schema I may be able to assist. However, unless the documents generated by PyXB violate the schema, changes to order of element and content is not a bug: order can only be preserved if order is enforced by the schema.