Skip to content

Commit

Permalink
Add basic metaschema tutorial for usnistgov#260.
Browse files Browse the repository at this point in the history
  • Loading branch information
aj-stein-nist committed Dec 16, 2022
1 parent 8dfb532 commit c3297c8
Showing 1 changed file with 32 additions and 2 deletions.
34 changes: 32 additions & 2 deletions website/content/tutorials/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,38 @@ menu:
weight: 10
---

Metaschema is a framework for modeling information into data formats. To start, let us imagine we want to exchange information about computers. How do we model a computer in Metaschema? We start with a metaschema definition.
Metaschema is a framework for modeling information into machine-readable data formats. If we want to build tools to exchange information about computers, how do we model a computer in Metaschema and what are the benefits?

We start with an empty metaschema definition, like the one below.

```xml
<METASCHEMA></METASCHEMA>
<?xml version="1.0" encoding="UTF-8"?
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
</METASCHEMA>
```

We write a Metaschema definition in XML. An empty definition like above has a beginning and ending `METASCHEMA` tags. We want to add useful metadata for both developers and Metaschema-enabled tools to consume this definition, like so.

```xml
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
<schema-name>Computer Model</schema-name>
<schema-version>0.0.1-alpha</schema-version>
<short-name>computer</short-name>
<namespace>http://example.com/ns/computer</namespace>
</METASCHEMA>
```

The metadata above provides useful information to the developer and tools. The `schema-name` is the long-form, descriptive name of the computer model. The `schema-version` is to give the model itself a version number, for either developers or their tools to use. The `short-name` is the shortened form of the `schema-name`, and most importantly the outputs of Metaschema-enabled tools will look for data fields with the name `computer`, not `Computer Model`. The `namespace` is a URI used to identify the model and its parts as belonging to a single scope, like a module name or class name in other data formats and programming languages.

With a minimal metadata section in place, we will add the first part of the model for the computer, an `assembly` for a computer itself.

```xml
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
<schema-name>Computer Model</schema-name>
<schema-version>0.0.1-alpha</schema-version>
<short-name>computer</short-name>
<namespace>http://example.com/ns/computer</namespace>

<define-assembly></define-assembly>
</METASCHEMA>
```

0 comments on commit c3297c8

Please sign in to comment.