Extensibility

Last modified 12 Mar 2021 10:22 +01:00

Axiom data models can be extended in a variety of ways:

  • Subtyping creates a new type that can be used instead of supertype.

  • Augmentation extends definition of an existing type.

  • Inframodel extensions can be used to modify Axiom language itself.

Subtyping

Subtyping is a method to create a new type that extends the capabilities of original type. Subtype can be used in all places where supertype can be used.

Augmentation

Axiom allows for model to introduce extension to other existing model, which has defined extension points.

model baseline {
  namespace "https://schema.example.com/ns/baseline";

  type User {
    property username;
    extensible true;
  }
}

model custom-ext {
  namespace "https://schema.example.com/ns/custom-ext";

  import {
    namespace "https://schema.example.com/ns/baseline";
    prefix baseline;
  }

  augmentation UserExtension {
    target baseline:User;
    property departmentId {
      type string;
    }
  }
}
XML example, extension element
<user>
  <username>administrator</username>
  <extension>
    <departmentId xmlns="https://schema.example.com/ns/custom-ext">DEP-01</departmentId>
  </extension>
</user>
XML example, namespaces only
<user>
  <username>administrator</username>
  <departmentId xmlns="https://schema.example.com/ns/custom-ext">DEP-01</departmentId>
</user>
YAML example
user:
  username: administrator
  extension:
    "https://schema.example.com/ns/custom-ext":
       departmentId: DEP-01

Unlike subtyping, augmentation does not define new data type. Augmentation extends the definition of an existing data type.

Use of namespaces is mandatory for reliable use of augmentation.

Was this page helpful?
YES NO
Thanks for your feedback