Most recently, I worked with some data for traffic and travel information, that is, data in Datex2 format. The project was short-lived and ended already, and I continued, as usual, and created a bunch of strongly typed C # classes with the xsd.exe tool, did serialization, light processing, and so on. However, now, looking back, I began to wonder if this was a good example for a provider like F #, and therefore I would take the first blow on this issue.
With this in mind, how should one approach a situation where there is a complex scheme that should not change often? Since there is no public type provider that would directly infer types from the schema, I think the parameters are:
- Use an XML type provider .
- Generate types with the external tool xsd.exe in this case - taking a cue from the WSDL type provider (which uses svcutil.exe ).
- Scan the types manually (possibly by changing the output of xsd.exe ).
- Generate types (as in the previous release) / use an XML type provider and perform continuous serialization, deserialization, and schema validation in the background.
Then I also started to wonder about the history of C # -F # (for example, generated or erased types), and what if I wanted to change the types in order to better check the constraints like <xs:element name="ilc" type="D2LogicalModel:TpegIlcPointDescriptor" maxOccurs="3"> in the schema, and provide a good developer experience.
Rolling your own types looks like a rather time-consuming end, and the last two points seem to be the most attractive, therefore, following the description below, nos in another SO post. I used System.Xml and System.CodeDom and modified the code to use Microsoft.FSharp.Compiler.CodeDom and FSharpCodeProvider to generate F # types.
Alas! The generated F # code does not compile (even after adding the appropriate references, etc.). At this moment, I thought that I could ask several directions.
Question: Is there a recommended, experienced way to create a type provider to conform to a somewhat complex XML scheme (taking into account Datex2 as an example), if I would like to use the restrictions as described in this scheme as early as possible in the development cycle?
<edit 2013-12-10: Rune FS is trying to hit this issue, see its SO question. Getting a compilation error in the provided type .