Binding to XML, JSON, and YAML

Note: This section of the specification is still a work in progress.

XML, JSON, and YAML each use specialized terminology and format primitives. As a notation for an object-based data, YAML is fairly similar to JSON, while XML is quite different to the other two. While all data format describe tree structures (directed graphs), each format (with its implicit data model) has its particular design, which requires specification in detail.

For example, a data point represented as an attribute on an element in XML, for example, might be a string property on a data object in JSON. The metaschema moderates this distinction by providing rules regarding its own semantic constructs and how they are to be represented in the target format. As a result, a mapping between JSON and XML concepts is implicitly available through the corresponding metaschema.

Within Metaschema-based models, all constructs are optional unless marked otherwise.

MetaschemaXMLJSON and YAML
AssemblyAn element with element contentAn object, either a property or a member of an array property
Field (with no flags)A single element with text contentString property
Field with one or more flagsAn element with text content, flags as attributesAn object property with a designated property for its nominal string value as well as properties for its flags
FlagAttributeString property
Flag with designated data typeAttribute with lexical constraints per typeString property with lexical constraints per type, or typed property such as number or URI (per type)
Field as-type='simple-markup', no flags permittedAn element permitting mixed content inlineString property or map with string property, parsable as markdown (line only)
Field as='complex-markup', flag(s) permittedAn element permitting mixed content inlineObject property with RICHTEXT String property or object with string property, parsable as markdown (full blocks)

XML Representational Form

Flag Instance

In XML, a flag instance is represented as an attribute.

<instance-effective-name flag-name="flag value"/>

Field Instance

In XML, a field is represented in two possible ways:

  1. As an XML element.

    The representational form of a field varies based on the presence of child flags.

    <field-name>field value</field-name>
    

    or

    <field-name flag="flag1 value">field value</field-name>
    

    The form immediately above is used when the field has a child flag instance.

  2. As a text value in an unwrapped form.

    <some-assembly>field value</some-assembly>
    

    This form is only allowed when a field has no child flags.

JSON Representational Form

Flag Instance

In JSON a flag instance is represented as an object member with an associated value.

{
  "flag-name": "flag value"
}

YAML Representational Form

Flag Instance

The YAML representation is similar to JSON, where a tagged value is used to represent a flag.

flag-name: flag value