#58 Values written when xsi:nil is set

None
closed
None
fixed
Content model
major
PyXB 1.0.0
defect
2011-09-09
2009-11-20
No

Following advise to try using nillable elements in schemata, I created a schema with a nillable element and generated a binding for it. The test document was read correctly but on output I noticed that the nil value was written as:

<ns1:assignedPriority xsi:nil="true">0</ns1:assignedPriority>

rather than

<ns1:assignedPriority xsi:nil="true" />

or

<ns1:assignedPriority xsi:nil="true"></ns1:assignedPriority>

I tried to reprocess the output from the binding and received the following stack trace:

Traceback (most recent call last):

File "./showbug.py", line 16, in <module>

et2 = TestSchema.CreateFromDOM(doc2.documentElement)

File "/diska/home/almamgr/almaworkspace/APDMTest/bugreport-20091120-2/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 2062, in _setContentFromDOM

self.extend(node.childNodes[:], _fallback_namespace)

File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 2040, in extend

[ self.append(_v, _fallback_namespace=_fallback_namespace) for _v in value_list ]

File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 1954, in append

value = element_binding._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 677, in init

super(simpleTypeDefinition, self).init(args, *kw)

File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 152, in init

self.checkNilCtor(args)

File "/alma/ACS-8.0/Python/lib/python2.5/site-packages/pyxb/binding/basis.py", line 130, in checkNilCtor

raise pyxb.ContentInNilElementError(args[0])

pyxb.exceptions_.ContentInNilElementError: 0

I've attached example code to demonstrate the behaviour.

2 Attachments

Discussion

  • Peter A. Bigot

    Peter A. Bigot - 2009-11-21

    Fix for #58, improper content for nil non-string simple types

     
  • Peter A. Bigot

    Peter A. Bigot - 2009-11-21
    • status changed from new to closed
    • resolution set to fixed
    • milestone changed from PyXB 1.1.0 to PyXB 1.0.1

    Fixed in [2079]. This change will be integrated into 1.0.1

     
  • anonymous

    anonymous - 2011-09-09
    • milestone PyXB 1.0.1 deleted

    Milestone PyXB 1.0.1 deleted

     

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:





No, thanks