Kevin - 2020-11-18

Good day!
I have been playing around with generateDS today to better utilize a number of XSD files in a Python application I am writing. We have a specific logging format that needs to meet this XSD format, and it is rather involved with multiple files that import one another. generateDS works really well - there is one oddity that I am trying to wrap my head around and am hoping that someone here can help.

One of the files is a simpleType with restricted enumeration values. In the file, "CVEnumAUDITActionType.xsd", the name of the simpleType is "CVEnumAuditActionType". When generateDS.py runs, it creates an enumeration class:

class CVEnumAuditActionType(str, Enum):
    """ DocString """
   ADD='ADD' 
   ...
   RESTART='RESTART' 

There are lots of enumerations that look good and appear fairly intuitive to use. However, I tried to use this class in the AuditRecordType. This worked, but then when I exported, it failed since the CVEnumAuditActionType lacked an export() method.

I banged my head on the keyboard for a little bit and then found another class that was generated:

class CVEnumAuditActionType1(GeneratedsSuper):
    """ DocString """
    ...methods...
    def export(self, ...)

When I created a CVEnumAuditActionType1 class instance, using the set_valueOf() function to set it to a CVEnumAuditActionType.ADD object, the export worked.

I noticed that I have two other classes with numbers appended on the end of them.

CVEnumAuditActionResultType2
CVEnumAuditTypeOfIdentityIdentifierType3

There are not classes with numbers on the end of them for all of the enumerations, though - just these three out of the many. My guess is that there's some conflict happening which is why there's a number added to the end of these - but I'm not sure of the logic.

My Questions

How can I predict when the numbers get appended to the Classes? Is there a way I can prevent that from happening? Can the classes for the enumeration be merged cleanly?

The schema files I am trying to generate from are available here:
https://www.dni.gov/index.php/features/223-about/organization/chief-information-officer?start=48

Configuration

Python 3.7.7 64-bit, Windows 10 x64
generateDS.py version 2.37.2

I created a new virtual environment at venv, and my command to generate my output is:

python venv\Scripts\generateDS.py -o icaudit.py -f --export="write etree literal" AUDIT\Schema\IC-AUDIT.xsd

Once it's generated, I use the following Python script to test it:

import sys
import ICAUDIT

if __name__=='__main__':
    record_list = ICAUDIT.AuditRecordListType()
    record = ICAUDIT.AuditRecordType()

    if True:
        # This does not work        
        action = ICAUDIT.CVEnumAuditActionType.ADD
    else:
        # This does work
        action = ICAUDIT.CVEnumAuditActionType1('ADD')

    record.set_Action(Action=action)    
    record_list.add_AuditRecord(record)
    record_list.export(sys.stdout, level=0, pretty_print=True)

    print("Done!")