XML and enumerations

4
Is there an easy way to map an XML string field which contains a restriction onto an enumeration with the same valid values set? For example, if an XML string field "status" contains a value in { "Complete", "Scheduled", "Billed" } this should map to a attribute in Mendix typed as enumeration Status with values xxx.Complete, xxx.Scheduled and xxx.Billed. You get an error if you just try to map the input string onto the enumeration in the model.
asked
1 answers
1

You could use a converter microflow to convert the XML input string to one of the enumeration values of your attribute. The microflow would have a String parameter as input and would return an enumeration value based on the value of the String parameter. You could use a single if-else if-else expression on the end event as follows:

if $stringValue = 'Complete' then
    Module.Enumeration.Complete
else if $stringValue = 'Scheduled' then
    Module.Enumeration.Scheduled
else if $stringValue = 'Billed' then
    Module.Enumeration.Billed
else
    empty
answered