Menu

#110 List element constrained with maxOccurs = 1 does not generate correctly when validation disabled

PyXB 1.1.4
closed
None
fixed
Binding model
major
PyXB 1.1.3
defect
2011-10-10
2011-10-10
No

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?

2 Attachments

Discussion

  • Peter Keller

    Peter Keller - 2011-10-10

    Test XSD

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-10-10
    • status changed from new to accepted

    Could well be related to those old ones: printing s.li suggests that the comment in #32 applies here (i.e., the element values are correct, but the secondary content array is wrong).

     
  • Peter A. Bigot

    Peter A. Bigot - 2011-10-10
    • status changed from accepted to closed
    • resolution set to fixed

    commit 65634f86e30cea0ecdc373b723974acf1dd85440
    Author: Peter A. Bigot <pabigot@‌>
    Date: Mon Oct 10 06:57:54 2011 -0500

    trac/110 bad unvalidated generation with simple list

    This patch appears to generate good content without causing anything to go
    wrong elsewhere, but fundamentally you can't expect generated XML to be
    valid if you turn off validation when generating.

     
MongoDB Logo MongoDB