Dear all

I had the following problem:

In an XSD schema I have an element “contourLevel” that takes a float value and 
has an attribute defined as follows:

 <xs:element name="contourLevel" minOccurs="0">
        <xs:complexType>
          <xs:simpleContent>
            <xs:extension base="xs:float">
              <xs:attribute name="source" type="xs:string" use="optional"/>
            </xs:extension>
          </xs:simpleContent>
        </xs:complexType>
      </xs:element>

An example XML snippet is as follows:
<contourLevel source="author">0.71</contourLevel>

The problem that I have is when the value is zero and write out the 
contourLevel element using a generateDS generated object.
What I get is:
<contourLevel source=“author”/>

My expectation is:
<contourLevel source="author”>0</contourLevel>

Looking through the file: generateDS.py
I found that this was because of the following code in the following method: 
def generateHascontentMethod(wrt, prefix, element)
the code:
 if element.getSimpleContent() or element.isMixed():
        if not firstTime:
            wrt(' or\n')
        firstTime = False
        wrt('            self.valueOf_’)

I modified to:

if element.getSimpleContent() or element.isMixed():
        if not firstTime:
            wrt(' or\n')
        firstTime = False
        wrt('            1 if type(self.valueOf_) in [int,float] else 
self.valueOf_’)

In this was a zero valued number is still considered as content. 

I was wondering if this was an acceptable solution to integrate into the main 
distribution?
The version I am working with is 2.17a0
Many thanks and best wishes

------------------------------------------------------------------------------
_______________________________________________
generateds-users mailing list
generateds-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/generateds-users

Reply via email to