summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorpab <bigot@acm.org>2009-11-20 17:23:29 -0700
committerpab <bigot@acm.org>2009-11-20 17:23:29 -0700
commite9efe8794b66f4a8ed9d799b25ea7a192189d755 (patch)
treed681c858999ed445814c5a0e94c21a60dc0a5daa
parente0adbe481460722be440c4014bc81d6233eaf7df (diff)
Fix trac #58
-rw-r--r--examples/content/showcontent.out3
-rw-r--r--pyxb/binding/basis.py2
-rw-r--r--tests/trac/test-trac-0058.py35
3 files changed, 39 insertions, 1 deletions
diff --git a/examples/content/showcontent.out b/examples/content/showcontent.out
index ebc4f51..216d087 100644
--- a/examples/content/showcontent.out
+++ b/examples/content/showcontent.out
@@ -1,4 +1,5 @@
-<?xml version="1.0" ?><numbers attribute="3"><simple>1</simple><complex style="decimal">2</complex></numbers>
+<?xml version="1.0" ?>
+<numbers attribute="3"><simple>1</simple><complex style="decimal">2</complex></numbers>
3
8
15
diff --git a/pyxb/binding/basis.py b/pyxb/binding/basis.py
index 1c24333..7f50fac 100644
--- a/pyxb/binding/basis.py
+++ b/pyxb/binding/basis.py
@@ -743,6 +743,8 @@ class simpleTypeDefinition (_TypeBinding_mixin, utility._DeconflictSymbols_mixin
The base class implementation delegates to the object class's
XsdLiteral method."""
+ if self._isNil():
+ return ''
return self.XsdLiteral(self)
@classmethod
diff --git a/tests/trac/test-trac-0058.py b/tests/trac/test-trac-0058.py
new file mode 100644
index 0000000..47243b3
--- /dev/null
+++ b/tests/trac/test-trac-0058.py
@@ -0,0 +1,35 @@
+import pyxb.binding.generate
+import pyxb.binding.datatypes as xs
+import pyxb.binding.basis
+import pyxb.utils.domutils
+
+import os.path
+xsd='''
+<xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
+ <xs:element name="iopt" nillable="true" type="xs:integer"/>
+</xs:schema>
+'''
+
+#file('schema.xsd', 'w').write(xsd)
+code = pyxb.binding.generate.GeneratePython(schema_text=xsd)
+#file('code.py', 'w').write(code)
+#print code
+
+rv = compile(code, 'test', 'exec')
+eval(rv)
+
+from pyxb.exceptions_ import *
+
+import unittest
+
+class TestTrac_0058 (unittest.TestCase):
+ def testRoundTrip (self):
+ xml = '<iopt xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"></iopt>'
+ instance = CreateFromDocument(xml)
+ self.assertTrue(instance._isNil())
+ self.assertEqual(0, instance)
+ self.assertEqual('', instance.xsdLiteral())
+ self.assertEqual(xml, instance.toxml(root_only=True))
+
+if __name__ == '__main__':
+ unittest.main()