Skip to content

Instantly share code, notes, and snippets.

@aj-stein-nist
Last active February 8, 2024 02:12
Show Gist options
  • Select an option

  • Save aj-stein-nist/d6877a8692e826552e083859aba7a333 to your computer and use it in GitHub Desktop.

Select an option

Save aj-stein-nist/d6877a8692e826552e083859aba7a333 to your computer and use it in GitHub Desktop.
Metaschema Tutorial 3 Model and Examples
{
"computer": {
"id": "awesomepc1",
"motherboard": {
"vendor": {
"id": "vendor2",
"name": "ISA Corp",
"address": "2000 K Street NW Washington, DC 20002",
"website": "https://example.com/isacorp/"
},
"type": "atx",
"cpu": {
"vendor": {
"id": "vendor2",
"name": "ISA Corp",
"address": "2000 K Street NW Washington, DC 20002",
"website": "https://example.com/isacorp/"
},
"product-name": "Superchip Model 1 4-core Processor",
"architecture": "arm64",
"speed": "4.7 gigahertz"
},
"ata-socket": {
"vendor": {
"id": "vendor2",
"name": "ISA Corp",
"address": "2000 K Street NW Washington, DC 20002",
"website": "https://example.com/isacorp/"
},
"product-name": "AwesomeSAS Model 1 Storage Socket",
"type": "sas"
},
"memory-modules": [
{
"vendor": {
"id": "vendor3",
"name": "Massive Memory Corp",
"address": "3000 K Street NW Washington, DC 20003",
"website": "https://example.com/massive-memory-corp/"
},
"product-name": "Erroneous Model 3 DDR4-3200 8GB (Module 1)",
"byte-size": 4
},
{
"vendor": {
"id": "vendor3",
"name": "Massive Memory Corp",
"address": "3000 K Street NW Washington, DC 20003",
"website": "https://example.com/massive-memory-corp/"
},
"product-name": "Model 3 DDR4-3200 8GB (Module 2)",
"byte-size": 4
}
]
}
}
}
<?xml version="1.0" encoding="UTF-8"?>
<computer xmlns="http://example.com/ns/computer" id="awesomepc1">
<vendor id="vendor1">
<name>AwesomeComp Incorportated</name>
<address>1000 K Street NW Washington, DC 20001</address>
<website>https://example.com/awesomecomp/</website>
</vendor>
<motherboard>
<vendor id="vendor2">
<name>ISA Corp</name>
<address>2000 K Street NW Washington, DC 20002</address>
<website>https://example.com/isacorp/</website>
</vendor>
<product-name>Magestic Model M-Ultra Motherboard</product-name>
<type>atx</type>
<cpu>
<vendor id="vendor2">
<name>ISA Corp</name>
<address>2000 K Street NW Washington, DC 20002</address>
<website>https://example.com/isacorp/</website>
</vendor>
<product-name>Superchip Model 1 4-core Processor</product-name>
<architecture>arm64</architecture>
<speed>4.7 gigahertz</speed>
</cpu>
<ata-socket>
<vendor id="vendor2">
<name>ISA Corp</name>
<address>2000 K Street NW Washington, DC 20002</address>
<website>https://example.com/isacorp/</website>
</vendor>
<product-name>AwesomeSAS Model 1 Storage Socket</product-name>
<type>sas</type>
</ata-socket>
<memory>
<vendor id="vendor3">
<name>Massive Memory Corp</name>
<address>3000 K Street NW Washington, DC 20003</address>
<website>https://example.com/massive-memory-corp/</website>
</vendor>
<product-name>Erroneous Model 3 DDR4-3200 8GB (Module 1)</product-name>
<size>1048555</size>
</memory>
<memory>
<vendor id="vendor3">
<name>Massive Memory Corp</name>
<address>3000 K Street NW Washington, DC 20003</address>
<website>https://example.com/massive-memory-corp/</website>
</vendor>
<product-name>Model 3 DDR4-3200 8GB (Module 2)</product-name>
<size>1048576</size>
</memory>
</motherboard>
</computer>
<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="https://raw.githubusercontent.com/usnistgov/metaschema/develop/schema/xml/metaschema.xsd" type="application/xml" schematypens="http://www.w3.org/2001/XMLSchema"?>
<METASCHEMA xmlns="http://csrc.nist.gov/ns/oscal/metaschema/1.0">
<schema-name>Computer Model</schema-name>
<schema-version>0.0.9</schema-version>
<short-name>computer</short-name>
<namespace>http://example.com/ns/computer</namespace>
<json-base-uri>http://example.com/ns/computer</json-base-uri>
<define-assembly name="vendor">
<formal-name>Vendor Information</formal-name>
<description>Information about a vendor of a computer part.</description>
<define-flag name="id" as-type="string" required="yes">
<formal-name>Vendor Identifier</formal-name>
<description>An identifier for classifying a unique computer parts vendor.</description>
</define-flag>
<model>
<define-field name="name" min-occurs="1" max-occurs="1">
<formal-name>Vendor Name</formal-name>
<description>The registered company name of the vendor.</description>
</define-field>
<define-field name="address" min-occurs="1" max-occurs="1">
<formal-name>Vendor Address</formal-name>
<description>The physical address of an office location for the vendor.</description>
</define-field>
<define-field name="website" as-type="uri" min-occurs="1" max-occurs="1">
<formal-name>Vendor Website</formal-name>
<description>A public website made by the vendor documenting their parts as used in the computer.</description>
</define-field>
</model>
</define-assembly>
<define-field name="product-name" as-type="string">
<formal-name>Product Name</formal-name>
<description>The product name from the vendor of the computer part.</description>
</define-field>
<define-assembly name="computer">
<formal-name>Computer Assembly</formal-name>
<description>A container object for a computer, its parts, and its sub-parts.</description>
<root-name>computer</root-name>
<define-flag name="id" as-type="string" required="yes">
<formal-name>Computer Identifier</formal-name>
<description>An identifier for classifying a unique make and model of computer.</description>
</define-flag>
<model>
<define-assembly name="motherboard">
<formal-name>Motherboard Assembly</formal-name>
<description>A container object for a motherboard in a computer and its sub-parts.</description>
<model>
<assembly ref="vendor"/>
<define-field name="type" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>Motherboard Type</formal-name>
<description>The type motherboard layout, <code>at</code>, <code>atx</code>, <code>mini-itx</code> or an alternative.</description>
</define-field>
<define-assembly name="cpu">
<formal-name>Motherboard Central Processing Unit (CPU)</formal-name>
<description>The model number of the CPU on the motherboard of a computer.</description>
<model>
<assembly ref="vendor"/>
<field ref="product-name" min-occurs="1" max-occurs="1"/>
<define-field name="architecture" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>CPU Architecture</formal-name>
<description>The Instruction Set Architecture (ISA) approved by module stakeholders.</description>
<constraint>
<allowed-values target="." allow-other="no">
<enum value="amd64">Intel 64-bit systems, also known as x86-64 or em64t</enum>
<enum value="armhf">Arm v7 32-bit systems</enum>
<enum value="arm64">Arm v8 64-bit systems</enum>
<enum value="x86">Intel 32-bit x86 systems, for 686 class or newer</enum>
</allowed-values>
</constraint>
</define-field>
<define-field name="speed" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>CPU Speed</formal-name>
<description>The clock speed of the CPU in megahertz or gigahertz.</description>
</define-field>
</model>
</define-assembly>
<define-assembly name="ata-socket">
<formal-name>Motherboard Advanced Technology Attachment (ATA) Socket</formal-name>
<description>The model number of ATA socket on the motherboard of a computer. There will only be one socket on any motherboard.</description>
<model>
<define-assembly name="vendor">
<formal-name>Vendor Information</formal-name>
<description>Information about a vendor of a computer part.</description>
<define-flag name="id" as-type="string" required="yes">
<formal-name>Vendor Identifier</formal-name>
<description>An identifier for classifying a unique computer parts vendor.</description>
</define-flag>
<model>
<define-field name="name" min-occurs="1" max-occurs="1">
<formal-name>Vendor Name</formal-name>
<description>The registered company name of the vendor.</description>
</define-field>
<define-field name="address" min-occurs="1" max-occurs="1">
<formal-name>Vendor Address</formal-name>
<description>The physical address of an office location for the vendor.</description>
</define-field>
<define-field name="website" as-type="uri" min-occurs="1" max-occurs="1">
<formal-name>Vendor Website</formal-name>
<description>A public website made by the vendor documenting their parts as used in the computer.</description>
</define-field>
</model>
</define-assembly>
<define-field name="product-name" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>Product Name</formal-name>
<description>The product name from the vendor of the computer part.</description>
</define-field>
<define-field name="type" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>ATA Socket Type</formal-name>
<description>The type of ATA socket on the motherboard with approved (but optional) values recommended by model stakeholders.</description>
<constraint>
<allowed-values target="." allow-other="yes">
<enum value="pata">Parallel ATA buses also known as AT-Attachment and IDE</enum>
<enum value="sata">Serial ATA buses supporting Advanced Host Controller Interface or legacy IDE modes</enum>
<enum value="esata">External Serial ATA buses for pluggable external devices using SATA</enum>
<enum value="esatap">External Serial ATA buses supporting SATA traffic and device power</enum>
</allowed-values>
</constraint>
</define-field>
</model>
</define-assembly>
<define-assembly name="memory" min-occurs="1" max-occurs="unbounded">
<formal-name>Motherboard Random Access Memory (RAM) Module(s)</formal-name>
<description>Random access memory hardware installed on the motherboard of a computer.</description>
<group-as name="memory-modules" in-json="ARRAY"/>
<model>
<define-assembly name="vendor">
<formal-name>Vendor Information</formal-name>
<description>Information about a vendor of a computer part.</description>
<define-flag name="id" as-type="string" required="yes">
<formal-name>Vendor Identifier</formal-name>
<description>An identifier for classifying a unique computer parts vendor.</description>
</define-flag>
<model>
<define-field name="name" min-occurs="1" max-occurs="1">
<formal-name>Vendor Name</formal-name>
<description>The registered company name of the vendor.</description>
</define-field>
<define-field name="address" min-occurs="1" max-occurs="1">
<formal-name>Vendor Address</formal-name>
<description>The physical address of an office location for the vendor.</description>
</define-field>
<define-field name="website" as-type="uri" min-occurs="1" max-occurs="1">
<formal-name>Vendor Website</formal-name>
<description>A public website made by the vendor documenting their parts as used in the computer.</description>
</define-field>
</model>
</define-assembly>
<define-field name="product-name" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>Product Name</formal-name>
<description>The product name from the vendor of the computer part.</description>
</define-field>
<choice>
<define-field name="byte-size" as-type="positive-integer" min-occurs="1" max-occurs="1">
<formal-name>Memory Module Size</formal-name>
<description>Size of the memory module in binary, not SI base-10 units, meaning a kilobyte is 1024 bytes, not 1000 bytes.</description>
</define-field>
<define-field name="size" min-occurs="1" max-occurs="1">
<formal-name>Memory Module Size</formal-name>
<description>Size of memory module in binary or SI base-10 units, optionally with a size unit. This does not require to be in bits or bytes.</description>
<!-- <define-flag name="unit" required="yes">
<formal-name>Memory Module Size Unit</formal-name>
<description>The unit size for a memory module can either be bytes (B) or bits (b).</description>
<constraint>
<allowed-values allow-other="no">
<enum value="B">byte</enum>
<enum value="b">bit</enum>
</allowed-values>
</constraint>
</define-flag>
<define-flag name="prefix-type" required="yes">
<formal-name>Memory Module Size Prefix Type</formal-name>
<description>The prefix type of module size, binary or decimal. This is useful if you will not specify an optional unit or unit type.</description>
<constraint>
<allowed-values allow-other="no">
<enum value="binary"/>
<enum value="decimal"/>
</allowed-values>
</constraint>
</define-flag>
<define-flag name="prefix">
<formal-name>Memory Module Size Unit Prefix</formal-name>
<description>The optional unit of size from a given system.</description>
<constraint>
<allowed-values allow-other="yes">
<enum value="Gi"></enum>
<enum value="Ki"></enum>
<enum value="Mi"></enum>
<enum value="G"></enum>
<enum value="K"></enum>
<enum value="M"></enum>
</allowed-values>
</constraint>
</define-flag>
<define-flag name="prefix">
<formal-name>Memory Module Size Unit Prefix System</formal-name>
<description>An identifier for the organization associated with the specific usage of unit prefix. If absent, the International System of Units (SI) is the presumed default.</description>
<constraint>
<allowed-values allow-other="yes">
<enum value="iec">The International Electrotechnical Commission 60027-2 Amendment 2 Units</enum>
<enum value="jedec">JEDEC Solid State Technology Association Units</enum>
<enum value="si">International System of Units</enum>
</allowed-values>
</constraint>
</define-flag> -->
</define-field>
</choice>
</model>
<constraint>
<expect id="memory-same-byte-size" level="WARNING" target="." test="if (count(./byte-size) > 0) then (sum(./byte-size) mod ./byte-size[1]) = 0 else (sum(./size) mod ./size[1]) = 0">
<message>All memory modules SHOULD be the same size or byte-size for a computer.</message>
</expect>
<!-- <expect id="memory-same-byte-size" level="WARNING" target="." test="(sum(./byte-size) mod ./byte-size[1]) = 0">
<message>All memory modules SHOULD be the same byte size for a computer. Use of byte-size is also deprecated.</message>
</expect>
<expect id="memory-same-size" level="WARNING" target="." test="(sum(./size) mod ./size[1]) = 0">
<message>All memory modules SHOULD be the same byte size for a computer.</message>
</expect> -->
</constraint>
</define-assembly>
<define-assembly name="expansion-card" min-occurs="0" max-occurs="unbounded">
<formal-name>Motherboard Expansion Card</formal-name>
<description>The model number of an expansion card connected to the motherboard of a computer.</description>
<group-as name="expansion-cards" in-json="ARRAY"/>
<model>
<define-assembly name="vendor">
<formal-name>Vendor Information</formal-name>
<description>Information about a vendor of a computer part.</description>
<define-flag name="id" as-type="string" required="yes">
<formal-name>Vendor Identifier</formal-name>
<description>An identifier for classifying a unique computer parts vendor.</description>
</define-flag>
<model>
<define-field name="name" min-occurs="1" max-occurs="1">
<formal-name>Vendor Name</formal-name>
<description>The registered company name of the vendor.</description>
</define-field>
<define-field name="address" min-occurs="1" max-occurs="1">
<formal-name>Vendor Address</formal-name>
<description>The physical address of an office location for the vendor.</description>
</define-field>
<define-field name="website" as-type="uri" min-occurs="1" max-occurs="1">
<formal-name>Vendor Website</formal-name>
<description>A public website made by the vendor documenting their parts as used in the computer.</description>
</define-field>
</model>
</define-assembly>
<define-field name="product-name" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>Product Name</formal-name>
<description>The product name from the vendor of the computer part.</description>
</define-field>
<define-field name="type" as-type="string" min-occurs="1" max-occurs="1">
<formal-name>Expansion Card Type</formal-name>
<description>The type of expansion card on a motherboard of a computer, such as <code>pci</code> (PCI, e.g. Peripheral Component Interconnect), <code>pcie</code> (PCI Express), or an alternative.</description>
</define-field>
</model>
</define-assembly>
</model>
</define-assembly>
</model>
</define-assembly>
</METASCHEMA>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment