Programmatic adding of schemas is designed to be able to modify schemas at runtime. You also have tools available for the transactional change of several schemas, as well as for mass data manipulation via XSLT. Like in the Editor, it is also not possible here to make a change to a schema if it contradicts the stock data in any form.

In addition to the content schema, also offers a structural schema. This indicates that only data objects of certain data types are permissible underneath a data object. Also, the modification of the structural schema is always checked against the stock data.

In the following example, an abstract root schema, a container schema and a schema for example data are created. The root and container schema serve for preventing disorder in your system. The root schema groups all schemas allocated to a purpose. In our case, it also provides a simple data type for re-use. The container schema is intended to form the structural root of all data allocated to a purpose.

using System;
using Onion.Client;

class Program
  private static void Main(string[] args)
    using (var session = new OnionSession("ipc://", "admin", "admin"))
      // fetch some necessary system schemata
      ISchema rootSchema = session.Schemata[""];
      ISchema userdefined = session.Schemata[""];

      // create an abstract root schema for our test types including a simple type
      ISchema exampleRootType = userdefined.Children.Create(
        @"<xs:schema xmlns:xs="""" 
            <xs:simpleType name=""specialNumber"">
              <xs:restriction base=""xs:integer"">
                <xs:minInclusive value=""3"" />
                <xs:maxInclusive value=""8"" />

      // create a container schema
      ISchema containerType = exampleRootType.Children.Create(
        @"<xs:schema elementFormDefault=""qualified""
            <xs:element name=""container"" />

      // allow the container to be created below the system root

      // add a simple data schema using our root schema
      ISchema dataType = exampleRootType.Children.Create(
        @"<xs:schema elementFormDefault=""qualified""
            <xs:include schemaLocation="""" />
            <xs:element name=""data"">
                  <xs:element name=""text"" type=""xs:string"" />
                  <xs:element name=""number"" type=""specialNumber"" />
                  <xs:element name=""dateTime"" type=""xs:dateTime"" />

      // allow the data schema to be created below the container

Over the property “IOnionSession.Schemata” you can get to all operations you need for editing the information model. The schemas are held in a hierarchical order. Self-contained models should be held below a root schema. XML schema offers the re-use of external schemas’ data types via the composition tool “xs:include” and “xs:import”. “xs:redefine” also belongs to this group and is the basis for object-oriented inheritance in

After you have executed the program, you can create the container object in the Editor below the system root and any example data objects below that.