2.15. The connection element

A connection element information item (referred to in this specification as a connection element) is an element in the CellML namespace with a local name equal to connection, which appears as a child of a model element.

  1. Each connection element MUST contain a component_1 attribute.

    1. The value of the component_1 attribute MUST be a valid component reference, as defined in 3.4 Component references.

  1. Each connection element MUST contain a component_2 attribute.

    1. The value of the component_2 attribute MUST be a valid component reference, as defined in 3.4 Component references.

See more

Creating connection items allows variable values to be passed between eligible components. There are both syntactic (i.e.: format) and semantic (i.e.: meaning) rules about how these must be specified, including what “eligible” means. Syntax will be discussed below and in the other “See more” blocks on this page. For more on the semantic rules, please see 3.10 Interpretation of map_variables elements.

Both points above are really saying the same thing. The way in which you specify the component_1 and component_2 items must follow the general CellML 2.0 format for a valid identifier, and must point to a component which exists under that name (note that this could be either an intantiated component, or an import component item).

<!-- This is a valid CellML 2.0 connection: -->
<model>
    <component name="house_of_capulet">
        <variable name="juliet" interface_type="public">
    </component>
    <component name="house_of_montague">
        <variable name="romeo" interface_type="public">
    </component>
    <connection component_1="montague" component_2="capulet">
        <map_variables variable_1="romeo" variable_2="juliet">
    </connection>
</model>

<!-- This is not valid: -->
<model>
    <component name="house_of_capulet">
        <variable name="juliet" interface_type="public">
    </component>
    <component name="house_of_montague">
        <variable name="romeo" interface_type="public">
    </component>

    <!-- The component_2 attribute does not exist as a component or import component name.-->
    <connection component_1="house_of_montague" component_2="CapuletWhanau">

        <!-- The variable_1 name is not a valid CellML identifier. -->
        <map_variables variable_1="Romeo, Romeo ..." variable_2="juliet">

    </connection>
</model>
  1. The value of the component_1 attribute MUST NOT be identical to the value of the component_2 attribute.

See more

All this means is that equivalent variables (i.e.: those specified by connection and map_variables items) must be in different components. Since the only reason you’d need to use these connections is in order to access a variable in another component, this restriction does kinda make sense!

<model>
    <component name="happily_ever_after">
        <variable name="juliet" interface_type="public">
        <variable name="romeo" interface_type="public">
    </component>

    <!-- This is not valid because component_1 and component_2 are the same. -->
    <connection component_1="happily_ever_after" component_2="happily_ever_after">
        <map_variables variable_1="romeo" variable_2="juliet">
    </connection>
</model>
  1. A CellML infoset MUST NOT contain more than one connection element with a given pair of components referenced by the component_1 and component_2 attribute values, in any order.

See more

You may only have one connection any two components, regardless of which is specified as component_1 and which is specified as component_2. If you have found duplicate connection elements, simply merge their contents - a connection can contain any number of map_variables children. Make sure that the order in which you specify the component attributes matches the order in which you specify their child variable items too: ie, all variable_1 items must be within the component_1 component and vice versa.

<!-- This is not valid CellML: -->
<model>
    <component name="house_of_capulet">
        <variable name="juliet" interface_type="public">
        <variable name="rosaline" interface_type="public">
    </component>
    <component name="house_of_montague">
        <variable name="romeo" interface_type="public">
    </component>

    <connection component_1="montague" component_2="capulet">
        <map_variables variable_1="romeo" variable_2="juliet">
    </connection>

    <!-- This connection duplicates the one above, even though
         component_1 and component_2 are swapped. -->
    <connection component_1="capulet" component_2="montague">
        <map_variables variable_1="rosaline" variable_2="romeo">
    </connection>
</model>

<!-- This is now valid: The contents were merged to create a valid model. -->
<model>
    <component name="house_of_capulet">
        <variable name="juliet" interface_type="public">
        <variable name="rosaline" interface_type="public">
    </component>
    <component name="house_of_montague">
        <variable name="romeo" interface_type="public">
    </component>

    <!-- The contents have been merged. Note that the order of variables
         must match the order of the parent component, i.e.: all variable_1s
         must be within component_1 etc. -->
    <connection component_1="montague" component_2="capulet">
        <map_variables variable_1="romeo" variable_2="juliet">
        <map_variables variable_1="romeo" variable_2="rosaline">
    </connection>
</model>
  1. A connection element MAY contain one or more map_variables element children.

See more

The point of creating a connection item is in order to connect variables between eligible components. You are allowed to have an empty connection, but it is meaningless.

<model>
    <component name="house_of_capulet">
        <variable name="juliet" interface_type="public">
    </component>
    <component name="house_of_montague">
        <variable name="romeo" interface_type="public">
    </component>

    <!-- Valid but redundant: an empty connection is meaningless. -->
    <connection component_1="montague" component_2="capulet">
    </connection>
</model>