Menu

Pyxb wrongly recognises simple type

2017-05-19
2017-05-19
  • Johnny Mazowski

    Johnny Mazowski - 2017-05-19

    Hello,

    I am dealing with creating XML file on the base of schema.
    Problem is with type recognition while assigning values to objects.
    My schema defines 2 simple types A and B (<xs:simpleType>) both similar but B has extra pattern restriction.

    Pyxb bidding classes ('An atomic simple type') are generated automatically in a way, that B inherits from A.

    class A (pyxb.binding.datatypes.string):
        ...
    
    class B (A):
        ...
    

    When I assign value to a complex element that is B type (by schema) just passing a string, the type of this element is recognized incorrectly.
    This does not performs pattern validation once building document .validateBinding() method - due to wrong type.

    my_elem = myschema_biddings()                      # some complex element
    my_elem.Nm = "Foo"                                 # no pattern validation !
    type(my_elem.Nm) = <class 'myschema_bidddings.A'>  # wrong
    my_elem.Nm = myschema_biddings.B("Bar")
    type(my_elem.Nm) = <class'myschema_bidddings.B'>   # correct
    

    I have asked this question on stack where You might find maybe some more details: http://stackoverflow.com/questions/43890710/pyxb-wrongly-recognises-simple-type

    Any help appreciated!

     
  • Peter A. Bigot

    Peter A. Bigot - 2017-05-19

    Update your StackOverflow post with the schema description for an element that uses those types and I'll answer it there.

     
  • Peter A. Bigot

    Peter A. Bigot - 2017-05-20

    Identified and resolved as github issue #78.

     

Log in to post a comment.