This wiki has undergone a migration to Confluence found Here
<meta name="googlebot" content="noindex">

Schema based code generation

From HL7Wiki
Jump to navigation Jump to search

Summary

When it comes to code generation one of the options is XML Schema based code generation. Schema based code generators exist for most programming languages.

  • An alternative to schema based code generation is MIF based code generation.
  • NOTE: this wiki page assumes that one uses the XML ITS 1.1 schema (and not the new RIM ITS schema).

Analysis

  • Note: schema based code generation is discussed in detail in the following tutorial: Implementation Mechanics (PPT). The tutorial has a Creative Commons license.

Code Generation (as a generic mechanism) has several advantages over manual coding. MIF based code generation has advantages over schema based code generation. The advantages and disadvantages are discussed below.

The XML schema (as published by HL7) aren't optimized for code generation. Prior to performing the code generation process one should transform the schema to optimize them for code generation and code re-use. See below for details.

Advantages and disadvantages

Code Generation versus manual coding:

  • Code Generation is an example of Model Driven Software development. The main advantages are flexibility and rapid development; the main disadvantage is that it may lead to a larger code base, and lower re-use of code for overlapping parts of models. See MDD for a full list of advantages.

Schema-based code generation versus MIF based code generation.

  • An advantage of schema based code generation is the wide availability of tools. MIF based code generators exist for Java and .net - but the choice is much more limited.
  • A serious disadvantage of schema based code generation is the fact that the XML schema language isn't powerful enough to express all of the constraints as contained in the MIF. The MIF contains the full details of the HL7 v3 model. The XML schema of the HL7 v3 model is derived from the MIF - with a loss of a significant amount of detail.

Optimization of the schema

Discussion