5.5 Practicing Contract-First XML Development with XSDObjectGenerator

XML is commonly used to integrate applications and is a common format for industry-standard documents. Organizations such as OASIS and ACORD define XML schemas for data exchange in commerce and insurance. These standardized schemas can be lengthy and complex, and creating XML to match these standards can be difficult.

XSDObjectGenerator can help solve this problem. Using this tool, you can generate a set of .NET classes to read and write XML by using the XML serialization attributes. XSDObjectGenerator is similar to the .NET Framework utility XSD.exe, discussed in the previous article. The primary difference is that XSDObjectGenerator creates classes that can be used to easily create XML documents with collections; XSD.exe generates arrays for XML schema sequences, while XSDObjectGenerator creates ArrayLists. You can easily add and delete elements with an array list, but you cannot change the number of elements in an array without re-creating the entire array.

XSDObjectGenerator allows you to do contract-first XML development. In contract-first development, you begin with an XML schema and create classes to reflect that schema, rather than beginning with .NET classes or DataSets and deriving schemas from them. Contract-first development is important in creating interoperable solutions, or where you are beginning development with an XML schema from a third party.

XSDObjectGenerator at a Glance

Tool

XSDObjectGenerator ...

Get Windows Developer Power Tools now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.