Problem creating a DMN programatically

I try to create a DMN programmatically.

  Dmn.writeModelToStream(new java.io.FileOutputStream(s"./$dmnId.out.dmn"), dmnModel)

This creates the following exception:

Caused by: org.xml.sax.SAXParseException; cvc-complex-type.2.4.b: The content of element 'rule' is not complete. One of '{"http://www.omg.org/spec/DMN/20151101/dmn.xsd":inputEntry, "http://www.omg.org/spec/DMN/20151101/dmn.xsd":outputEntry}' is expected.

I took the excel importer as an example.

Here is the code - how I created the Rule:

  private def dmnRule(postcode: Integer, place: String, userFin: String) = {
    val rule = dmnModel.newInstance(classOf[Rule])
    val inputEntry = dmnModel.newInstance(classOf[InputEntry])
    rule.addChildElement(inputEntry)

    val userFinIn = dmnModel.newInstance(classOf[InputEntry])
    rule.addChildElement(userFinIn)
    decisionTable.addChildElement(rule)
  }

If I check the Debugger - it shows that I have the requested inputEntry:

Any ideas?

You have to have at least one outputEntry.

2 Likes

@langfr thanks - this line was the problem:

    val userFinIn = dmnModel.newInstance(classOf[InputEntry])

Copy-Paste Error - Just forgot to change the In to the Out. And the Error message oneOf took me on the wrong foot :grimacing:.