The xsd2code++ code generation tool translates an XML or JSON Schema Definition (XSD) source file into computer language C# or VB source files. These source files contain an application programming interface (API) that allows programmatic data to be encoded to XML, JSON, BSON format and decoded to programmatic variables. Each variable is of a type that corresponds to a type, element, or attribute defined within the XML or JSON schema document. Each XSD or JSON source file results in the generation of C# classes that represent each of the XSD or JSON types and global elements contained within the Schema source file. These classes contain encode, decode, and utility functions.
The power of xsd2code++ is to produce code that does not require the use of any external library. The code is 100% DotNet native and allows you to adapt it to your needs.
This is a walk-through that takes you through the process of developing an XML & JSON Data Binding Component from an XML Schema (XSD) or JSON Schema (JSON).
It is assumed that you have a working knowledge of XSD & JSON and either C#, VB .Net.
The concepts covered are:
The different examples in this document will be based on the following schema:
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://tempuri.org/PurchaseOrderSchema.xsd" targetNamespace="http://tempuri.org/PurchaseOrderSchema.xsd" elementFormDefault="qualified"> <xsd:element name="PurchaseOrder" type="tns:PurchaseOrderType"/> <xsd:complexType name="PurchaseOrderType"> <xsd:sequence> <xsd:element name="ShipTo" type="tns:USAddress" maxOccurs="2"/> <xsd:element name="BillTo" type="tns:USAddress"/> </xsd:sequence> <xsd:attribute name="OrderDate" type="xsd:date"/> </xsd:complexType> <xsd:complexType name="USAddress"> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> <xsd:element name="street" type="xsd:string"/> <xsd:element name="city" type="xsd:string"/> <xsd:element name="state" type="xsd:string"/> <xsd:element name="zip" type="xsd:integer"/> </xsd:sequence> <xsd:attribute name="country" type="xsd:NMTOKEN" fixed="US"/> </xsd:complexType> </xsd:schema>
{ "$schema": "http://json-schema.org/draft-04/schema#", "description": "Generated by xsd2code++. www.xsd2code.com", "definitions": { "PurchaseOrderType": { "type": "object", "properties": { "ShipTo": { "type": "array", "items": { "$ref": "#/definitions/USAddress" }, "minItems": 1, "maxItems": 2 }, "BillTo": { "$ref": "#/definitions/USAddress" }, "OrderDate": { "type": "string" } }, "required": [ "BillTo" ] }, "USAddress": { "type": "object", "properties": { "name": { "type": "string" }, "street": { "type": "string" }, "city": { "type": "string" }, "state": { "type": "string" }, "zip": { "type": "integer" }, "country": { "type": "string" } }, "required": [ "name", "street", "city", "state", "zip" ] } }, "type": "object", "additionalProperties": false, "properties": { "PurchaseOrder": { "$ref": "#/definitions/PurchaseOrderType" } } }
Using these examples you can follow our quickstart guide