Search code examples
xsdbond

Is there a way to generate Microsoft Bond schema from XSD schema?


I want to try out Microsoft Bond schema. I already have a large XSD file and I don't want to manually create a Bond file. Does the Bond compiler provide any API to convert XSDs to Bond?


Solution

  • No API exists to directly convert from an XSD to a .bond file or to a Bond schema.

    The Bond type system is different from the XSD type system, so there isn't a 1-to-1 mapping. For example, Bond has no type to represent a duration of time. XSD has no map type like Bond's. (Of course, conventions could be established to map between the type systems, but no such conventions have become firmly established.)

    Sometimes people generate an XSD schema from hand-written C# types. If you're in that situation, you could use Bond's attributes to decorate the same types. Then, you could ask Bond for the RuntimeSchema of that type, which you could use to mechanically generate the .bond file.