1.2. CellML information sets

1.2.1. CellML and XML

  1. Every CellML infoset SHALL be represented in an XML information set which conforms with the well-formedness requirements of XML 1.1 [5].

  2. In this document, the remaining provisions relating to CellML infosets SHALL be interpreted as additional constraints on the XML information set represented by a CellML infoset.

1.2.2. Specific information items

  1. For the purposes of this specification, a specific information item is one of the following (see https://www.w3.org/TR/2004/REC-xml-infoset-20040204/ for definitions):

    1. A document information item;

    2. An element information item;

    3. An attribute information item;

    4. A processing instruction information item;

    5. An unexpanded entity reference information item;

    6. A document type declaration information item;

    7. An unparsed entity information item; or

    8. A notational information item.

  2. Specific information items MUST NOT appear in a CellML infoset except where explicitly allowed by this specification, or where allowed by a normative specification referenced by this specification.

  3. The order in which specific information items appear, as children of an element information item defined in this specification, SHALL NOT affect the semantic interpretation of the CellML model.

See more

Specific information items

There are different kinds of information stored in XML elements. In the example below, the food_ideas element has:

  • title, instructions, ingredient have text content (note that numbers like 1.0 are treated as text),

  • ingredients and food_ideas have element contents, because they have child elements inside them,

  • category is an attribute of the recipe element, and name and units are attributes of the ingredient element, and

  • the note within <!-- ... --> comment tags is of an unparsed type and is ignored.

<food_ideas>
  <recipe category="easy">
    <title>Three ingredient scones</title>
    <!-- These are so easy ... and if you're clever you'll save a little cream for whipping on the top! -->
    <ingredients>
      <ingredient name="cream" units="cup">1.0</ingredient>
      <ingredient name="lemonade" units="cup">1</ingredient>
      <ingredient name="selfraising_flour" units="cup">4</ingredient>
    </ingredients>
    <instructions>
      Mix them all together using your hands.
      You can use extra flour if you need to.
      Bake at 220C for about 12 minutes or until golden.
    </instructions>
  </recipe>
</food_ideas>

Using CellML this could be written:

<model name="recipes">
  <units name="cup">
    <unit units="litre" prefix="milli" multiplier="250.0" />
  </units>
  <component name="Three_ingredient_scones">
    <!-- Sigh ... if only it were possible for my computer to make me tea ... -->
    <variable name="cream" cellml:units="cup" initial_value="1" />
    <variable name="lemonade" cellml:units="cup" initial_value="1"  />
    <variable name="selfraising_flour" cellml:units="cup" initial_value="5" />
    <variable name="mixture" cellml:units="cup" />
    <math>
      <apply><eq/>
        <ci>mixture</ci>
        <apply><plus/>
          <ci>cream</ci>
          <ci>lemonade</ci>
          <ci>selfraising_flour</ci>
        </apply>
      </apply>
    </math>
  </component>
  <!-- BUT THIS IS NOT VALID! -->
  <extra type="Danger_Will_Robinson">
    Even though this looks like a valid XML text block, it's not allowed here.  Only those
    elements which are explicitly specified as types of children are allowed!
  </extra>
</model>

1.2.3. Non-specific information items

  1. For the purposes of this specification, a non-specific information item is one of the following (see https://www.w3.org/TR/2004/REC-xml-infoset-20040204/ for definitions):

    1. A comment information item;

    2. A namespace information item; or

    3. A character information item.

  2. An element information item in the CellML namespace MUST NOT contain any character information items, except for whitespace characters.

See more

<!-- This is not valid! -->
<model name="myInvalidCellML">
  ... because it has stuff here that shouldn't be here.
</model>
  1. Two CellML infosets SHALL be deemed semantically equivalent if one can be transformed into the other by making zero or more of the following changes:

    1. Adding, removing, and/or modifying comment information items.

    2. Changing (inserting, removing, and/or modifying) one or more namespace information items, and/or modifying the prefix of one or more information items, without changing the namespace that any information item is in.

    3. The following paragraph applies to character information items which are the direct child of an element information item in the CellML namespace, or in the MathML namespace: inserting or removing character information items that consist entirely of whitespace characters, changing the number of whitespace characters in such an information item, or changing the number of whitespace characters at the beginning or end of any character information item.

See more

Semantic equivalence

The example below is identical to that in the previous “See more” block because:

  • newlines, tabs, whitespace do not affect equivalence (except as part of text or attribute content),

  • the order of element definition does not affect equivalence,

  • the order of attribute definition does not affect equivalence, and

  • comments do not affect equivalence.

<model name="recipes">
  <component name="Three_ingredient_scones">
    <!--
       Comments are ignored ...
       so here's a really long one about how much I now
       feel like yummy scones and jam and cream and tea ...
    -->

    <!-- The order of child elements is ignored -->
    <math>
      <apply><eq/>
        <ci>mixture</ci>
        <apply><plus/>
          <ci>cream</ci>
          <ci>lemonade</ci>
          <ci>selfraising_flour</ci>
        </apply>
      </apply>
    </math>

    <!-- Whitespace (including tab, new line, and space) between attributes is ignored. -->
    <variable
      name="selfraising_flour"
      cellml:units="cup"
    />
     <variable         name="cream"           cellml:units="cup"          />

    <!-- Whitespace (including tab, new line, and space) between elements is ignored. -->



    <variable cellml:units="dimensionless"  name="mixture" /><variable name="lemonade" cellml:units="cup" />
  </component>
  <units name="cup">
    <!-- The order of attributes within an element is ignored. -->
    <unit multiplier="250.0" prefix="milli"  units="litre" />
  </units>
</model>

1.2.4. Use of namespaces

  1. Element information items in a CellML infoset MUST belong to one of the following namespaces, unless explicitly indicated otherwise:

    1. The CellML namespace; or

    2. The MathML namespace.

  2. Attribute information items in a CellML element MUST NOT be prefixed with a namespace, unless explicitly indicated otherwise.

1.2.5. XML ID Attributes

  1. Any element information item in the CellML namespace MAY contain an attribute with local name id. This attribute SHALL be treated as having attribute type ID, as defined in Section 3.3.1 of XML 1.1 [5].

See more

Understanding element IDs

In order to understand how the XML id attribute is used in CellML models, we need to understand four things. Firstly, in CellML the elements are identified by uniqueness over the model scope of their name attribute, their type (eg: variable), and in some cases, by their parent element too. Secondly, the CellML model might exist over several different documents, and make use of import functionality to connect these documents into one model. Thirdly, the uniqueness of the XML id attribute value extends only to the document scope, not the CellML model scope. Finally, there are aspects of the written XML which do not contribute to the conceptual model as represented by the CellML; simple examples are things like whitespace between elements, comments, quotation and angle bracket markers. These are all parts of the written language which guide interpretation into the conceptual model. The id attribute is likewise an XML attribute which falls into the same category: it may be read when a document is parsed, but as it doesn’t form a part of any CellML element, it doesn’t exist in the constructed conceptual representation. Having said this, the syntax of CellML is a subset of XML (as specified in CellML information sets), so the rules of XML id attributes must be followed, where present.

Consider the example below.

# In the document "BreakfastMenu.cellml".
# All id attributes are unique within this document.
model: name = "BreakfastOfChampions", id = "b"
  ├─ component: name = "Protein", id = "p"
  ├─ component: name = "Carbohydrates", id = "c" <╴╴╴╴╴╴╴╴╴┐
  └─ component: name = "FunStuff", id = "f"                ╷
       └─ variable: name = "FunStuff", id = "fs"           ╷
                                                           ╷
                                        Valid: A CellML component named "Porridge" is
                                        imported, but its XML id attribute "p" is not
                                        a part of that import.
                                                           ╵
# In the document "CarbohydrateIdeas.cellml".              ╵
# All id attributes should be unique within this document. ╵
model: name = "Carbs" id = none specified                  ╵
  ├─ component: name = "Chocolate", id = "c"               ╵
  ├─ component: name = "Porridge", id = "p" ╴╴╴╴╴╴╴╴╴╴╴╴╴╴╴┘
  └─ component: name = "Toast", id = "t"
      └─ variable: name = "Peanutbutter", id = "p"

      # Invalid: The variable Peanutbutter is not allowed to have an id of "p"
      # as this conflicts with the component Porridge id "p" in the same document.

See CellML syntax

<!-- In the file BreakfastMenu.cellml: -->
<model name="BreakfastOfChampions" id="b">
  <component name="Protein" id="p" />

  <import href="CarbohydrateIdeas.cellml">
    <!-- Valid: The id attribute value is set here to be "c"
         rather than that of the import, "p" -->
    <component name="Carbohydrates" id="c" component_ref="Porridge" />
  </import>

  <!-- Valid: The name attributes are repeated, but in different element types.
       The id attributes are distinct. -->
  <component name="FunStuff" id="f" />
    <variable name="FunStuff" id="fs" units="sprinkles" />
  </component>
</model>

<!-- In the file CarbohydrateIdeas.cellml: -->
<model name="Carbs">
  <!-- The id attribute "c" here does not clash with the Carbohydrates
       component above as they are unknown to each other,
       and in different documents. -->
  <component name="Chocolate" id="c" />

  <!-- Valid: The id attribute "p" here does not clash with the Protein
       component id above because even though they are in the same model,
       they are in different documents. -->
  <component name="Porridge" id="p" />

  <component name="Toast" id="t">
    <!-- Invalid: The id attribute "p" here does clash with the component
         Porridge above because they are in the same document. -->
    <variable name="Peanutbutter" id="p" units="smooth" />
  </component>
</model>

Some points to note:

  • Here we have two separate documents which are partially combined to make one model.

  • There is no repetition of id attribute values within the BreakfastMenu.cellml document.

  • There is repetition of the name attribute “FunStuff”, but the elements have different types (component and variable), so this remains valid.

  • There is repetition of the id attribute “p” in the CarbohydrateIdeas.cellml document, between the variable named “Peanutbutter” and the component named “Porridge”. This is not valid.