There are four officially supported data formats for serializing NineML: XML, JSON, YAML, and HDF5 (although it is possible to use other data formats). When referenced from another NineML document, the format of a NineML file is recognised by the extension of its filename, i.e:

Format Extension
XML .xml
JSON .json
YAML .yml
HDF5 .h5


Tools that plan to support NineML only need to support one data format since the officially supported NineML Python Library can be used to convert between the data formats listed above.

NineML is intended to be an abstract object model that is independent of the choice of hierarchical data format used to serialize it. However, some aspects of NineML were designed with XML in mind and there are some subtle differences between hierarchical data formats that prevent general mappings from XML. Therefore, in order to map the NineML object model onto non-XML data formats some additional conventions are required.

Several features of XML that are used in the NineML specification and are not present in JSON/YAML (JSON and YAML are equivalent representations), and/or HDF5 are:

Namespaces (xmlns):
There is no concept of namespaces in JSON/YAML or HDF5, which are used in NineML to distinguish the document version and annotations.
In JSON/YAML there is no concept of attributes. This does not pose a problem if a given NineML type does not have body text as attributes can be treated as separate children. However, for NineML types that do, such as Constant and Definition, both the body text and attributes can’t be represented without additional conventions.
Sets of child elements:
While there are list structures in JSON/YAML, which can be used to represent arbitrarily sized sets of child elements (e.g. parameters, properties, regimes), HDF5 does not have an equivalent structure for storing sets of objects of the same type.

Fortunately, JSON, YAML and HDF5 all permit arbitrary strings as field names, whereas element/attribute names in XML must start with an alphabetic character. Therefore we can use non alphanumeric characters, in this case the ‘@’ symbol, to escape the following special fields.

Holds the namespace of the element as the special attribute xmlns does in XML.
Used to differentiate body text from other attributes in JSON/YAML and HDF5 iff there are other attributes (Datasets could technically be used as body elements in HDF5 but they are designed to hold array data not single values). Note that for JSON/YAML and HDF5 if the serial form of an element only contains body text (e.g. MathInline) then this is “flattened” to be the sole value of the element.
A HDF5 group that has a @multiple attribute equal to ‘true’, contains multiple child elements of the given NineML type, which are stored as sub-groups named by arbitrary integer indices. Note that this is not strictly required for elements in the NineML specification (although it simplifies code to read them), where the multiplicity of children of a given type is defined, but is for parsing arbitrary object hierarchies in annotations.


Future versions of NineML will be designed to minimise the need for the the @body field within the NineML object model. However, it will still be required to represent arbitrary annotations and language extensions designed in XML.

ArrayValues should also be stored within native data array structures of the format (e.g. HDF5 datasets) instead of within ArrayValueRow elements.

The following model of a Izhikevich neuron uses both shows an example of how namespaces and body elements are represented natively in XML.

<?xml version='1.0' encoding='UTF-8'?>
<NineML xmlns="">
  <ComponentClass name="Izhikevich">
    <Parameter name="C_m" dimension="capacitance"/>
    <Parameter name="a" dimension="per_time"/>
    <Parameter name="alpha" dimension="per_time_voltage"/>
    <Parameter name="b" dimension="per_time"/>
    <Parameter name="beta" dimension="per_time"/>
    <Parameter name="c" dimension="voltage"/>
    <Parameter name="d" dimension="voltage_per_time"/>
    <Parameter name="theta" dimension="voltage"/>
    <Parameter name="zeta" dimension="voltage_per_time"/>
    <AnalogReducePort name="Isyn" dimension="current" operator="+"/>
    <EventSendPort name="spike"/>
    <AnalogSendPort name="V" dimension="voltage"/>
      <StateVariable name="U" dimension="voltage_per_time"/>
      <StateVariable name="V" dimension="voltage"/>
      <Regime name="subthreshold_regime">
        <TimeDerivative variable="U">
          <MathInline>a*(-U + V*b)</MathInline>
        <TimeDerivative variable="V">
          <MathInline>-U + V*beta + alpha*(V*V) + zeta + Isyn/C_m</MathInline>
        <OnCondition target_regime="subthreshold_regime">
            <MathInline>V &gt; theta</MathInline>
          <StateAssignment variable="U">
            <MathInline>U + d</MathInline>
          <StateAssignment variable="V">
          <OutputEvent port="spike"/>
      <Validation xmlns="" dimensionality="True"/>
  <Component name="SampleIzhikevich">
    <Definition url="./izhikevich.xml">Izhikevich</Definition>
    <Property name="C_m" units="pF">
    <Property name="a" units="per_ms">
    <Property name="alpha" units="per_mV_ms">
    <Property name="b" units="per_ms">
    <Property name="beta" units="per_ms">
    <Property name="c" units="mV">
    <Property name="d" units="mV_per_ms">
    <Property name="theta" units="mV">
    <Property name="zeta" units="mV_per_ms">
    <Initial name="U" units="mV_per_ms">
    <Initial name="V" units="mV">
  <Dimension name="capacitance" m="-1" l="-2" t="4" i="2"/>
  <Dimension name="current" i="1"/>
  <Unit symbol="mV" dimension="voltage" power="-3"/>
  <Unit symbol="mV_per_ms" dimension="voltage_per_time" power="0"/>
  <Unit symbol="pF" dimension="capacitance" power="-12"/>
  <Unit symbol="per_mV_ms" dimension="per_time_voltage" power="6"/>
  <Unit symbol="per_ms" dimension="per_time" power="3"/>
  <Dimension name="per_time" t="-1"/>
  <Dimension name="per_time_voltage" m="-1" l="-2" t="2" i="1"/>
  <Dimension name="voltage" m="1" l="2" t="-3" i="-1"/>
  <Dimension name="voltage_per_time" m="1" l="2" t="-4" i="-1"/>

whereas in YAML the @namespace and @body fields must be used in place of the xmlns attribute and body text.

   - name: Izhikevich
     - {name: C_m, dimension: capacitance}
     - {name: a, dimension: per_time}
     - {name: alpha, dimension: per_time_voltage}
     - {name: b, dimension: per_time}
     - {name: beta, dimension: per_time}
     - {name: c, dimension: voltage}
     - {name: d, dimension: voltage_per_time}
     - {name: theta, dimension: voltage}
     - {name: zeta, dimension: voltage_per_time}
     - {name: Isyn, dimension: current, operator: +}
     - {name: spike}
     - {name: V, dimension: voltage}
       - {name: U, dimension: voltage_per_time}
       - {name: V, dimension: voltage}
       - name: subthreshold_regime
         - {MathInline: a*(-U + V*b), variable: U}
         - {MathInline: -U + V*beta + alpha*(V*V) + zeta + Isyn/C_m, variable: V}
         - Trigger: {MathInline: V > theta}
           target_regime: subthreshold_regime
           - {MathInline: U + d, variable: U}
           - {MathInline: c, variable: V}
           - {port: spike}
       - {'@namespace': '', dimensionality: 'True'}
   - Definition: {'@body': Izhikevich, url="./izhikevich.yml"}
     name: SampleIzhikevich
     - {name: C_m, SingleValue: 1.0, units: pF}
     - {name: a, SingleValue: 0.2, units: per_ms}
     - {name: alpha, SingleValue: 0.04, units: per_mV_ms}
     - {name: b, SingleValue: 0.025, units: per_ms}
     - {name: beta, SingleValue: 5.0, units: per_ms}
     - {name: c, SingleValue: -75.0, units: mV}
     - {name: d, SingleValue: 0.2, units: mV_per_ms}
     - {name: theta, SingleValue: -50.0, units: mV}
     - {name: zeta, SingleValue: 140.0, units: mV_per_ms}
     - {name: U, SingleValue: -1.625, units: mV_per_ms}
     - {name: V, SingleValue: -70.0, units: mV}
   - {name: capacitance, m: -1, l: -2, t: 4, i: 2}
   - {name: current, i: 1}
   - {name: per_time, t: -1}
   - {name: per_time_voltage, m: -1, l: -2, t: 2, i: 1}
   - {name: voltage, m: 1, l: 2, t: -3, i: -1}
   - {name: voltage_per_time, m: 1, l: 2, t: -4, i: -1}
   - {symbol: mV, dimension: voltage, power: -3}
   - {symbol: mV_per_ms, dimension: voltage_per_time, power: 0}
   - {symbol: pF, dimension: capacitance, power: -12}
   - {symbol: per_mV_ms, dimension: per_time_voltage, power: 6}
   - {symbol: per_ms, dimension: per_time, power: 3}

Example representation of sets of Parameter elements in HDF5 format:

/NineML/ComponentClass/Parameter/@multiple = true
/NineML/ComponentClass/Parameter/0/name = 'C_m'
/NineML/ComponentClass/Parameter/0/dimension = 'capacitance'
/NineML/ComponentClass/Parameter/1/name = 'a'
/NineML/ComponentClass/Parameter/1/dimension = 'per_time'