A while ago, I heard about xmllint, a program that can parse and query xml from the command-line.
Later, I discovered it can also parse html, can recover from xml/html errors and has an interactive shell that has a lot of commands (see table below) to navigate through the loaded command.
The relevant command-line options:
--recover
--html
--shell
Note that --recover will output failing input to stderr. You can ignore that using 2> /dev/null
It comes down to these cases for XML elements having maxOccurs="1" (which the default for maxOccurs):
adding nillable="true" will convert from a regular type to a nullable type.
adding minOccurs="0" will add boolean …Specified properties in the generated C# for each element.
you can have both nillable="true" and minOccurs="0" in an element which gets you a nullable type and a …Specified property.
Note I’m not considering fixed or default here, nor attributes (that have use instead of minOccurs/maxOccurs, but do not allow for nillable) nor larger values of maxOccurs (which both xsd.exe and xsd2code regard as unbounded).
From the above, XML has a richer type system than C#, so in XML there are subtle a differences between:
an explicit nil in the XML element
the XML element being absent
the XML element being empty.
Hopefully later more text and examples to show how to actually work with this.
One of the things you cannot do in XSD, is have string enumerations contain both a key and a value.
But there is a little appinfo trick inside annotation that you can user under some circumstances, for instance when you interpret the XSD:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
appinfo is the application counterpart of documentation: both can contain any xml, but appinfo is aimed at machines, whereas documentation is aimed at humans.