Create dmn document using dmn moddle

I am using dmn moddle in my own diagramming library to create and validate the dmn diagram.
While creating the dmn xml using dmn moddle.
i am able to create decision table but unable to create input, output elements and append it to decision table. below is my code that i have tried.

moddle.fromXML(file, root, (err, definitions) => {
  var decision = moddle.create('dmn:Decision',{
          id: "xyz"
        })
   var table = moddle.create('dmn:DecisionTable',{
          id: 'zxy'
        })    
 var input = moddle.create('dmn:InputClause', {
      id: '123'
    })
        table.hitPolicy = ""
        table.extensionElements = input
        definitions.get('drgElement').push(decision)
        decision.decisionLogic = table
})

can anyone help me in understanding how i can add input element to decision table.
The output for this code is

<?xml version="1.0" encoding="UTF-8"?>
<definitions xmlns="https://www.omg.org/spec/DMN/20191111/MODEL/" xmlns:camunda="http://camunda.org/schema/1.0/dmn" id="Definitions_1" name="Definitions" namespace="http://camunda.org/schema/1.0/dmn">
  <decision id="xyz">
    <decisionTable id="zxy" hitPolicy="">
      <inputClause id="123" />
    </decisionTable>
  </decision>
  <informationRequirement />
</definitions>

but i want element in the decision table. Thanks in advance

Isn’t it exactly what you see here?

<decisionTable id="zxy" hitPolicy="">
   <inputClause id="123" />
</decisionTable>

Or did you mean something different?

No this is what i am expecting

<decisionTable id="zxy" hitPolicy="">
   <input id="123" />
</decisionTable>

Is the “Input” element an official DMN element or something custom from your side?

“Input” element is there in the camunda modeler. Whenever we create a decision table with its input and output column , we get that tag

Ah ok, I see. So you’ll have to set the newly created input clause as input array property of the table

table.input = [input];

You can also refer to that example and see that the input element is written into the exported XML (integrated in dmn-js)

Thank you… it works. and i had one more doubt…
I wanted to add inputExpression in the input tag… i used.

 var exp = moddle.create('dmn:LiteralExpression', {
      id: 'yyy'
    })
input.inputExpression = [exp]

But its doesnt work.
My expected output is

<input id="input_1" label="ok " camunda:inputVariable="fine">
        <inputExpression id="inputExpression_1" typeRef="string" expressionLanguage="FEEL">
          <text>hi </text>
        </inputExpression>
      </input>

Please see that the inputExpression property of input clauses is not a list, cf. descriptor.

Hint: these DMN schema files are very good resources to understand the model behind the toolkit. Note, that these are DMN 1.3 related, if you’re using an older version of dmn-moddle, you’ll have to refer to the old DMN 1.1 version.