Using Code Templates


The template node registers a template that can be used to avoid duplicate code when extending the generated code, and it is a child of the typesystem node.

    <template name="my_template">
        // the code

Use the insert-template node to insert the template code (identified by the template’s name attribute) into the generated code base.


The insert-template node includes the code template identified by the name attribute, and it can be a child of the inject-code, conversion-rule or template nodes.

<inject-code class="target" position="beginning">
    <insert-template name="my_template" />

Use the replace node to modify the template code.


The replace node allows you to modify template code before inserting it into the generated code, and it can be a child of the insert-template node.

<insert-template name="my_template">
   <replace from="..." to="..." />

This node will replace the attribute from with the value pointed by to.