List element constrained with maxOccurs = 1 does not generate correctly when...
Brought to you by:
pabigot
Generate from attached schema as follows:
pyxbgen --schema-location=test.xsd --module=T
Generate and output an element with:
import pyxb
import T
s = T.tSingle()
s.li = T.intList([1,2,3])
pyxb.RequireValidWhenGenerating(False)
print s.toxml()
and the output is:
<ns1:tSingle xmlns:ns1="http://www.example.com/">
<li>1</li>
<li>2</li>
<li>3</li>
</ns1:tSingle>
With validation enabled, the output is correct:
<?xml version="1.0"?>
<ns1:tSingle xmlns:ns1="http://www.example.com/">
<li>1 2 3</li>
</ns1:tSingle>
I experimented a bit with maxOccurs > 1, and did not manage to get this behaviour, so it seems to be specific to the case where maxOccurs=1
Speculation: is there some relationship here with the old tickets 32 and 35?
Test XSD
Could well be related to those old ones: printing
s.lisuggests that the comment in #32 applies here (i.e., the element values are correct, but the secondary content array is wrong).commit 65634f86e30cea0ecdc373b723974acf1dd85440
Author: Peter A. Bigot <pabigot@‌>
Date: Mon Oct 10 06:57:54 2011 -0500
Patch to generate correct content