add possibility to dynamically change component type - fix #233

This PR adds the possibility to change the component type when using a dynamic component reference - in practice this means that a reference can first refer to a template (without controller) or a component (with controller) - and vice versa.

Technically, template and components inherit from different base classes, this is why the solution was to dynamically create a new node instance when a change in component type is detected, and replace the current instance with the new instance. I also made sure that all component types now create surrounding comment nodes (aka. node1 and node2) as they can only be created by the first instance, and are then reused by the next ones.