Bad constraint for 'base64Binary'
Brought to you by:
pabigot
"base64Binary" values apparently want check a length contraint but do not define a meaningfull "XsdValueLength" method.
I hit this problem while trying to construct an XML Signature
"Signature" value:
DigestValue()
This results in a traceback:
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 1349, in __call__
return self.typeDefinition().Factory(*args, **kw)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 227, in Factory
rv = cls._DynamicCreate(*args, **kw)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 509, in _DynamicCreate
return ctor(*args, **kw)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 751, in __init__
self.xsdConstraintsOK()
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 884, in xsdConstraintsOK
return self.XsdConstraintsOK(self)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 877, in XsdConstraintsOK
if not f.validateConstraint(value):
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/facets.py", line 194, in validateConstraint
return self._validateConstraint_vx(value)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/facets.py", line 350, in _validateConstraint_vx
value_length = value.xsdValueLength()
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/basis.py", line 916, in xsdValueLength
return self.XsdValueLength(self)
File "/home/dieter/bfd/plone/Python-2.4/lib/python2.4/site-packages/pyxb/binding/datatypes.py", line 705, in XsdValueLength
raise NotImplementedError('No length calculation for base64Binary')
NotImplementedError: No length calculation for base64Binary
The corresponding schema http://www.w3.org/TR/xmldsig-core/ is
<simpleType name="DigestValueType">
<restriction base="base64Binary"/>
</simpleType>
Workaround -- but probably not the best solution. More likely: do not add constraints facets when the schema does not call for them
In fact, the error is correct. xs:base64Binary is completely unimplemented.
Now that xs:hexBinary has paved the way for representations where the value and lexical space are not distinguishable by Python type, it would be possible to implement this type. I'll look into that.
base64Binary has been implemented in branch trac/96, which has also been merged to next. Will be in next release.