Replace Element in process model using camunda model api

Dear Community,

currently, I am using the camunda model api to modify a process model. Specifically, I am trying to replace an intermediate none event by a timer event.

FlowNode event3 = (FlowNode) modelInstance.getModelElementById("Event_2");
IntermediateThrowEvent timerEvent = modelInstance.newInstance(IntermediateThrowEvent.class);

TimerEventDefinition timerEventDefinition = modelInstance.newInstance(TimerEventDefinition.class);
TimeCycle cycle = modelInstance.newInstance(TimeCycle.class);
timerEventDefinition.setTimeCycle(cycle);
cycle.setTextContent("R3/PT30S");
timerEvent.addChildElement(timerEventDefinition);
process.replaceChildElement(event3, timerEvent);

The event gets replaced. However, the namespace bpmn is missing.
So the result is:

<intermediateThrowEvent id="intermediateThrowEvent_88db893c-237d-41ff-8fc0-57d3fedc8f51" xmlns="http://www.omg.org/spec/BPMN/20100524/MODEL">
  <incoming>Flow_2</incoming>
  <outgoing>Flow_0fgsn1t</outgoing>
  <timerEventDefinition id="timerEventDefinition_543f6a37-6b30-46f8-8b9d-1d4522202292">
    <timeCycle id="timeCycle_c1b64517-2948-4ee9-92a6-7b4df5d6e5a6">R3/PT30S</timeCycle>
  </timerEventDefinition>
</intermediateThrowEvent>

In the modeler the event is displayed as intermediate timer event. However, the time cycle is not displayed. When I deploy the model to the engine, the timer is ignored and the token passes the event without waiting for the timer.

If I fix the structure and add the bpmn: namespace, the modeler displays the event correctly and the engine executes the process properly.

So the question arises, why does the camunda model api not add the correct namespace and how can I add it in order to get it working.

Furhtermore, if I try the camunda model api example from the docs: Create a Model | docs.camunda.org
The modeler cannot read the generated process model and the model cannot be executed in the engine. Is this the supposed result?

Any hints are appreciated.

I could figure it out myself. It was a very silly mistake.

The Timer Event is of course a catch event. Consequently, the code needs to be changed to

 IntermediateCatchEvent timerEvent = modelInstance.newInstance(IntermediateCatchEvent.class);

It had nothing to do with the namespace bpmn: