Menu

Order of the content generated through pyxb

Help
Lavanya
2018-06-14
2018-06-14
  • Lavanya

    Lavanya - 2018-06-14

    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.

     
  • Peter A. Bigot

    Peter A. Bigot - 2018-06-14

    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).

     
  • Lavanya

    Lavanya - 2018-06-14

    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.

     
  • Lavanya

    Lavanya - 2018-06-14

    I set the following values and tried to generate. It still does not preserve the order

    pyxb.ValidationConfig()._setForDocument(False) 
    pyxb.ValidationConfig()._setForBinding(False)
    
     
  • Peter A. Bigot

    Peter A. Bigot - 2018-06-14

    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.

     

Log in to post a comment.

MongoDB Logo MongoDB