Thanks for the info techgnome; that sounds logical enough in the general case...
However, in this specific case a command may only ever have 0 or 1
ReadProtocol, that is the
<ReadProtocol> element has
maxoccurs=1 and
minoccurs=0. Which is to say that a given command may either be readable or not, if it is readable, then it is read from using a certain protocol... a command cannot be read using multiple protocols as a command with a different protocol would be a different command. So perhaps your starting problem is sort of a non-problem in this case?
Nevertheless, to follow it down to:
xml Code:
<ReadProtocol>
<Name>FooReadProtocolEnumMember</Name>
<ReadLength>10</ReadLength>
<ReadLengthIsVariable>False</ReadLengthIsVariable>
</ReadProtocol>
This brings an issue with friendly names for types. A
<ReadProtocol> should probably map to a
class ReadProtocol type. The type that collects possible read protocols for
Name should probably be
enum ReadProtocol. Now we have a type clash in the XSD (
ReadProtocol simple type for the enum and same for complex type for the element with nested elements) and also for the C# (
ReadProtocol for the enum and same for the class).
Although the
<ReadProtocol> complex type could possibly be anonymous (in the case where there is a maximum of 1 read protocol) but that looks bad, does not work if there are to be multiple read protocols and still does not solve the clash in C#. Unless the
Name type was
enum ReadProtocolName, but again that starts to seem ... clunky and as such seems like a code smell maybe?
PS: I cannot just use
Protocol for either the class or the enum type name to avoid this clash, because that would then clash with solving the same problem for the
WriteProtocol which obviously has a different set of protocol names and so a different enum.