Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "Creating a message batch, using an XML data source as example"

 
(6 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Image:Within OHF, message instances are special XML files that are created according to an [www.hl7.org/ Health Level 7] model. We'll use one such message instance, <code>UKCT_EX120901UK01.xml</code>.
+
Within OHF, message instances are special XML files that are created according to a [http://www.hl7.org/ Health Level 7] model. For this example, we'll use one such message instance, <code>UKCT_EX120901UK01.xml</code>. (A similar file, message_instance_example.xml, can be found in the <code>data</code> directory of the <code>tests</code> plugin.)
 
When generated, the message looks something like this (if viewed within the [http://www.b2international.com/web/guest/products/mie Message Instance Editor]):
 
When generated, the message looks something like this (if viewed within the [http://www.b2international.com/web/guest/products/mie Message Instance Editor]):
  
Line 11: Line 11:
  
  
[[Image:TemplatesInserted.PNG]]  
+
[[Image:Datafile.PNG]]  
  
  
Line 21: Line 21:
  
  
 +
[[Image:TemplatesInserted.PNG]]
  
  
Line 26: Line 27:
 
<code>Window->Preferences->OHF H3ET->Batch Generator->XML Batch Data Source</code>:
 
<code>Window->Preferences->OHF H3ET->Batch Generator->XML Batch Data Source</code>:
  
picture of preference page with data location set
 
  
We are now ready to invoke the wizard which will guide us through the batch generation. We right-click on the sample message instance and select  
+
[[Image:XmlPreference.PNG]]
<code>New->Other->Message Instance Batch</code>
+
 
 +
 
 +
We are now ready to invoke the wizard which will guide us through the batch generation. We right-click on the sample message instance in the <code>Package Explorer</code> and select  
 +
<code>New->Other->Message Instance Batch</code>:
 +
 
 +
 
 +
[[Image:NewWizards.PNG]]
  
picture of selecting the wizard
 
  
 
We first choose the sample message instance (it is already selected since we right-clicked on it, so we just accept).
 
We first choose the sample message instance (it is already selected since we right-clicked on it, so we just accept).
  
picture of file selection page about to click next
+
 
 +
[[Image:FileSelection.PNG]]
 +
 
  
 
We then choose a location for the output batch. This must be an existing location in our workspace.  
 
We then choose a location for the output batch. This must be an existing location in our workspace.  
  
picture of output location page with location selected and about to click next
+
 
 +
[[Image:OutputLocation.PNG]]
 +
 
  
 
The last page of the wizard allows us to set some options. First, we select XML as the data source. The next option allows us to restrict the number of files created. This can be useful if the database is very large, but in the present case we will use all of the available data and create as many files as we can. The last option allows us to specify how the batch files are named; we will just use the default. The default batch name uses the same name and extension as the sample message file, but appends an underscore and index to each created file. For example, if we create 2 files using a sample message called <code>sample.xml</code>, the output files will be called <code>sample_1.xml</code> and <code>sample_2.xml</code>. After these options have been selected, the options page looks like this:
 
The last page of the wizard allows us to set some options. First, we select XML as the data source. The next option allows us to restrict the number of files created. This can be useful if the database is very large, but in the present case we will use all of the available data and create as many files as we can. The last option allows us to specify how the batch files are named; we will just use the default. The default batch name uses the same name and extension as the sample message file, but appends an underscore and index to each created file. For example, if we create 2 files using a sample message called <code>sample.xml</code>, the output files will be called <code>sample_1.xml</code> and <code>sample_2.xml</code>. After these options have been selected, the options page looks like this:
  
picture of options page with all options set as described above
 
  
Finally, we press ''Finish''. The batch generator creates the batch messages, and opens up the folder in which they are contained. Each created file has had the token replaced with the appropriate values from the data file.  
+
[[Image:OptionsPage.PNG]]
 +
 
 +
 
 +
Finally, we press ''Finish''. The batch generator creates the batch messages, and opens up the folder in which they are contained.  
 +
 
 +
 
 +
[[Image:Explorer.PNG]]
 +
 
 +
 
 +
Each created file has had the token replaced with the appropriate values from the data file. The first file gets data from the first  set of elements/attributes, the second file from the second, etc.
 +
 
 +
 
 +
[[Image:Output1.PNG]]
 +
 
 +
 
 +
The number of files created equals the size of the largest source of data from the XML data file. For example, in our sample <code>data.xml</code> file, there are 6 <code>value1</code> values and only 5 <code>value2/@value</code> values. The generator therefore creates 6 files, and in the 6th file inserts an empty string when <code>value2/@value</code> cannot supply any more values.
 +
 
  
pictures of created files
+
[[Image:Output6.PNG]]
]]
+

Latest revision as of 11:10, 17 August 2007

Within OHF, message instances are special XML files that are created according to a Health Level 7 model. For this example, we'll use one such message instance, UKCT_EX120901UK01.xml. (A similar file, message_instance_example.xml, can be found in the data directory of the tests plugin.) When generated, the message looks something like this (if viewed within the Message Instance Editor):


Designview.PNG


In order to indicate to the generator that a certain field should be populated by outside data, we must put a token in that field. A token has the form ${name}, where name must be something meaningful to the data source (see the tutorials on the different data sources for more on this). For the XML data source, the token must be an XPath to the data in the XML data file. For example, let's use the following data file, called data.xml:


Datafile.PNG


We will use the data in the value1 element, and the value attribute of the value2 element. The corresponding XPath queries are /database/data/table1/value1 and /database/data/table2/value2/@value.

We place these tokens into the sample message instance (we first switch to the source view of the Message Instance Editor):


TemplatesInserted.PNG


Before generating the message batch, we first must specify the location of the data file. This is done on the preference page accessed through Window->Preferences->OHF H3ET->Batch Generator->XML Batch Data Source:


XmlPreference.PNG


We are now ready to invoke the wizard which will guide us through the batch generation. We right-click on the sample message instance in the Package Explorer and select New->Other->Message Instance Batch:


NewWizards.PNG


We first choose the sample message instance (it is already selected since we right-clicked on it, so we just accept).


FileSelection.PNG


We then choose a location for the output batch. This must be an existing location in our workspace.


OutputLocation.PNG


The last page of the wizard allows us to set some options. First, we select XML as the data source. The next option allows us to restrict the number of files created. This can be useful if the database is very large, but in the present case we will use all of the available data and create as many files as we can. The last option allows us to specify how the batch files are named; we will just use the default. The default batch name uses the same name and extension as the sample message file, but appends an underscore and index to each created file. For example, if we create 2 files using a sample message called sample.xml, the output files will be called sample_1.xml and sample_2.xml. After these options have been selected, the options page looks like this:


OptionsPage.PNG


Finally, we press Finish. The batch generator creates the batch messages, and opens up the folder in which they are contained.


Explorer.PNG


Each created file has had the token replaced with the appropriate values from the data file. The first file gets data from the first set of elements/attributes, the second file from the second, etc.


Output1.PNG


The number of files created equals the size of the largest source of data from the XML data file. For example, in our sample data.xml file, there are 6 value1 values and only 5 value2/@value values. The generator therefore creates 6 files, and in the 6th file inserts an empty string when value2/@value cannot supply any more values.


Output6.PNG

Back to the top