I have an XML schema which defines a datatype based on hexBinary with a length restriction like so:
<xs:attribute name="Color" use="optional">
This is then used in a tag attribute in an XML document like this:
<Font ID="Arial" Color="FFFFFFFF" Weight="normal" Size="40">
Where the Color value should evaluate to a length of 4. However on loading the XML document, I get the following error:
Type <class 'libdcp.xsd.dcpschema.smpte_subtitle.STD_ANON_9'> length constraint violated by value FFFFFFFF
I checked the generated pyxb module and STD_ANON_9 is indeed the "Color" datatype.
>>> from binascii import unhexlify
It seems to me that this might be a bug in pyxb (I didn't find anything related to this in the Trac, so I'm posting this here.)
Peter A. Bigot
It is a bug, though not with the restriction length. In an attribute context the constructor is bypassing the hexBinary functions that convert the lexical space value. Should be fixed later today.
Confirmed, bug recorded as trac/216, and patch committed in next branch. This will be in PyXB 1.2.3 due to be released today or tomorrow.
Good catch. Thanks.
Awesome, thanks for the quick fix :)