XsdConfGen Plugin - Usage

The xsdconfgen plugin takes an XML conformance profile and creates an equivalent XSD (XML Schema) document which can be used to validate XML encoded messages conformant to that profile.

This can be useful when using customized message structures with toolsets that require a schema document in order to function.

Using the Plugin

Usage of the plusing is as follows:

<plugin>
   <groupId>ca.uhn.hapi</groupId>
   <artifactId>hapi-sourcegen</artifactId>
   <version>2.2</version>
   <executions>
      <execution>
         <id>xsdgen</id>
         <goals>
            <goal>xsdconfgen</goal>
         </goals>
         <configuration>
            
            <!-- The directory to put the generated XSD in -->
            <targetDirectory>${basedir}/target/generated-sources/xsdconfgen</targetDirectory>
            
            <!-- The filename of the generated XSD -->
            <targetFile>XSDGEN.xsd</targetFile>
            
            <!-- 
            One or more XML conformance profiles. If more than one is used,
            the contents will be combined. Note that this has the effect of 
            merging the profiles in a specific way: When an element is found in
            a profile for the first time (e.g. a definition for the PID segment),
            that element is generated into the XSD. If the same element is found
            in a subsequent profile, it is ignored and the definition from the first
            profile is used.
            
            This is desirable if you want to process multiple message types in
            certain toolsets and reuse modules for processing some structures.
            
            If completely separate definitions are desired, this can be accomplished
            by configuring the xsdconfgen plugin to have multiple executions and 
            to use only a single conformance profile for each execution.
            -->
            <profiles>
               <profile>${basedir}/src/test/resources/ca/uhn/hl7v2/conf/parser/ADT_A01.xml</profile>
               <profile>${basedir}/src/test/resources/ca/uhn/hl7v2/conf/parser/example_ack.xml</profile>
            </profiles>
            
            <!-- 
            Optional:
            If set to true, elements in the profile with a usage of "X" 
            meaning "not supported" will not be generated in the XSD 
            -->
            <constrain>false</constrain>
            
            <!-- 
            Optional:
            This can be used to create additional message/structure types linked to
            a structure defined by the conformance profile. In this example, we have
            linked to a conformance profile above which profides the structure
            of ADT_A01. The entries below give us message definitions in our XSD 
            for messages ADT_A02 and ADT_A03 which use the ADT_A01 structure.  
            -->
            <linkTriggerToStructure>
               <ADT_A02>ADT_A01</ADT_A02>
               <ADT_A03>ADT_A01</ADT_A03>
            </linkTriggerToStructure>
            
         </configuration>
      </execution>
   </executions>				
</plugin>