I tried parsing and generating an incomplete XML document using the advice from Ticket #44. The following stack trace appeared.
Processing file: TestDoc.xml
Traceback (most recent call last):
File "./showbug.py", line 12, in <module>
et = TestSchema.CreateFromDOM(doc.documentElement)
File "/diska/home/almamgr/almaworkspace/APDMTest/bugreport-20091120/TestSchema.py", line 42, in CreateFromDOM
return pyxb.binding.basis.element.AnyCreateFromDOM(node, _fallback_namespace=default_namespace)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 1290, in AnyCreateFromDOM
return elt._createFromDOM(node, expanded_name, _fallback_namespace=_fallback_namespace)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 1441, in _createFromDOM
rv = type_class.Factory(_dom_node=node, _fallback_namespace=fallback_namespace, **kw)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 205, in Factory
rv = cls._DynamicCreate(args, *kw)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 468, in _DynamicCreate
return ctor(args, *kw)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 1603, in init
self._setContentFromDOM(dom_node, fallback_namespace)
File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 2064, in _setContentFromDOM
raise pyxb.MissingContentError()
pyxb.exceptions_.MissingContentError
I've attached sample code to demonstrate the fault.
Patch relative to 1.0.0 to work around #57
Fixed in [2077]. As noted in #44, PyXB is currently not set up for non-validating use. The flag that's causing the problem here is deep enough that it's not clear whether parsing or generating is being done. The attached patch "fixes" this by using the conjunction of Parsing+Generating validation to determine whether validation should occur.
This fix is unlikely to go into 1.0.1.