The DMN 1.1 standard includes a new interchange format that soon will become public. Meanwhile, DMCommunity Apr-2016 Challenge provides a very simple xml-file for the decision model “Vacation Days” created by Bruce Silver. Ideally, DM vendors may take this file (and much more complex DMN XML files), transform it to their own format, and execute using their own tools. While vendors are not in a hurry to support DMN XML yet, this weekend I decided to give it a try. Below I will describe the results.
I’ve created a relatively simple Java program that can do the following:
- read an xml-file created in the DMN interchange format
- extract all decision tables from this file
- automatically generate an Excel file with the proper decision tables presented in the OpenRules executable format in different Excel worksheets.
For example, for the DMCommunity Apr-2016 Challenge Bruce took this Trisotech decision table
Later on, I should also be able to additionally generate a table “Glossary” and a table “Decision” that invokes all other decision tables. However, for now it is quite simple to do it manually in Excel to be able to execute the generated decision tables. It is important that the same program already can generate Excel not with just one but all (!) decision tables, which were extracted from the DMN XML file.
More Complex Example
Bruce Silver kindly provided this xml-file that represents his implementation of the lending decision model described in the DMN Specification in the Chapter 11. After reading this DMN XML format my program generated the following xls-file with all 8 decision tables.
Open Source Software
I plan to advance this Java project and add it to our open source installation as a part on the upcoming OpenRules new release. However, it is already can be reused by other vendors. If you are interested, please feel free to contact me and I may provide you with all sources and explanations.
Here is a brief description of this Java project that includes the following:
- DmnXmlReader.java – an abstract class that can read a DMN file and extract from it all key decision model elements. My quick first implementation extracts all decision tables and represents them in an array of the instances of the class DecisionTable. Each vendor may create a concrete subclass (such as DmnXmlReaderOpenRules.java) that defines only a few simple methods which specify how to handle input and output formulas, quotes, non-applicable entries (by default DMN uses ‘-‘) and other vendor-specific information
- DecisionTable.java – currently contains a decision table attributes including its name, hit policy, input and output decision variables, and all rules with various input and output entries
- VendorGenerator – an interface that currently defines only one method “generate” with two parameters: an array of decision tables generated by DmnXmlReader and the name of the file in which all these tables should be written. In particular, my implementation of this interface is called OpenRulesGenerator and it generates all decision tables into an Excel file in the OpenRules format. It should be easy for other vendors to create their own generators.
I plan to advance these Java interfaces beyond decision tables. I hope this work would be helpful to promote the DMN interchange among different BR&DM vendors.