Warning:
This wiki has been archived and is now read-only.

SemProM XML Format

From Object Memory Modeling Incubator Group Wiki
Jump to: navigation, search

The following text is intended to serve as an example or starting point for further discussion. An XML binding for Semantic Product Memories (SemProMs) is proposed which builds on the SemProM Container Format Version 1.0. The following text is based on a text written by Alexander Claus from SAP Research Dresden.


Motivation

To be able to communicate Semantic Product Memories (SemProMs) over network, to share it between applications or to store it, it is convenient to have an XML binding for the SemProM instead of processing the binary format only.

The following is a proposal for such an XML binding. The format is aligned with the capabilities of the binary format, i.e. for further uses it may be enhanced a lot.

The block types Ids, Core, Structure and Attributes specified in SemProM binary format v1.0 are encoded into XML according XML schema files depicted in the next sections. To handle meta information about the SemProM blocks there is also an XML schema file. The section “semprom.xsd” proposes an XML binding for complete SemProMs making use of all previously defined XML schemata. This XML encoding can be used also as encoding for SemProM blocks of type SemProm.

XML Binding

Ids Block

The XML binding for the Ids block follows the same requirements as in the binary format specification: There has to be exactly one primary ID and zero or many other IDs. As stated in the binary format specification: "In the unlikely case that a SemProM has IDs but not a primary ID, it can specify a primary ID of type ‘none’."

As there are different encodings for each of the listed ID types, one has additionally agree upon an encoding for each of these IDs, or an additional attribute has to be introduced declaring the encoding of the ID. For a first convention one could use the encoding as declared in the SemProM binary format specification v1.0 thereby encode pure byte arrays into Base64 strings.

Additionally to the pure content of the block data the schema file declares an optional attribute blockID which can be used to put the information into context. It may be omitted if only the content is relevant.

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/ids#" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://semprom.de/ids#">

    <xs:element name="idsBlockData" type="tns:idsBlockType" />

    <xs:complexType name="idsBlockType">
        <xs:sequence>
            <xs:element name="primaryID" type="tns:idElemType" />
            <xs:element name="id" type="tns:idElemType" minOccurs="0" maxOccurs="unbounded" />
        </xs:sequence>
        <xs:attribute name="blockID" type="xs:int" use="optional" />
    </xs:complexType>

    <xs:complexType name="idElemType">
        <xs:simpleContent>
            <xs:extension base="xs:string">
                <xs:attribute name="idType" type="tns:idType" />
            </xs:extension>
        </xs:simpleContent>
    </xs:complexType>

    <xs:simpleType name="idType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="none" />
            <xs:enumeration value="uri" />
            <xs:enumeration value="rfid" />
            <xs:enumeration value="gid96" />
            <xs:enumeration value="sgtin96" />
            <xs:enumeration value="sgtin198" />
            <xs:enumeration value="sscc96" />
            <xs:enumeration value="sgln96" />
            <xs:enumeration value="sgln195" />
            <xs:enumeration value="grai96" />
            <xs:enumeration value="grai170" />
            <xs:enumeration value="giai96" />
            <xs:enumeration value="giai202" />
            <xs:enumeration value="gsrn96" />
            <xs:enumeration value="gdti96" />
            <xs:enumeration value="gdti113" />
            <xs:enumeration value="dod96" />
            <xs:enumeration value="mac48" />
            <xs:enumeration value="bluetooth" />
            <xs:enumeration value="eui64" />
            <xs:enumeration value="zigbee64" />
            <xs:enumeration value="ipv4" />
            <xs:enumeration value="ipv6" />
            <xs:enumeration value="custom" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Core Block

The XML binding for the Core block follows the same requirements as in the binary format specification: All attributes except the ‘version’ attribute are optional. The version attribute has to contain the value ‘1.0’ for version 1.0. Possible attributes are:

  • version (Has to contain the value ‘1.0’ for version 1.0.)
  • product_name (optional)
  • product_type (optional)
  • company_name (optional)
  • part_number (optional)
  • instance_name (optional)
  • description (optional)
  • length (optional)
  • width (optional)
  • height (optional)
  • weight (optional)
  • handling_info (optional)
  • Error_code (optional)

Additionally to the pure content of the block data the schema file declares an optional attribute blockID which can be used to put the information into context. It may be omitted if only the content is relevant.

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/core#" xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://semprom.de/core#">

    <xs:element name="coreBlockData" type="tns:coreBlockType" />

    <xs:complexType name="coreBlockType">
        <xs:all>
            <xs:element name="version" type="xs:string" minOccurs="1" maxOccurs="1" />
            <xs:element name="product_name" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="product_type" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="company_name" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="part_number" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="instance_name" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="description" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="length" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="width" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="height" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="weight" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="handling_info" type="xs:string" minOccurs="0" maxOccurs="1" />
            <xs:element name="Error_code" type="xs:string" minOccurs="0" maxOccurs="1" />
        </xs:all>
        <xs:attribute name="blockID" type="xs:int" use="optional" />
    </xs:complexType>
</xs:schema>

Structure Block

The XML binding for the Structure block follows the same requirements as in the binary format specification: The block contains the state of the SemProM and a list of relational records. Each record has to refer to exactly one primary ID, but can refer also to zero or more other IDs. The XML schema refers to the XML schema of the Ids block for the enumeration of ID types declared in that document. For the encoding of the IDs the same remarks apply as described in Section Ids Block.

Additionally to the pure content of the block data the schema file declares an optional attribute blockID which can be used to put the information into context. It may be omitted if only the content is relevant.

structureBlockData.xsd

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/structure#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:tns="http://semprom.de/structure#"
    xmlns:spmid="http://semprom.de/ids#">

    <xs:import namespace="http://semprom.de/ids#" schemaLocation="idsBlockData.xsd" />

    <xs:element name="structureBlockData" type="tns:structureBlockType" />

    <xs:complexType name="structureBlockType">
        <xs:sequence>
            <xs:element name="state" type="tns:sempromState" />
            <xs:element name="record" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:sequence>
                        <xs:element name="primaryID" type="spmid:idElemType" />
                        <xs:element name="id" type="spmid:idElemType"
                            minOccurs="0" maxOccurs="unbounded" />
                    </xs:sequence>
                    <xs:attribute name="recordType" type="tns:relationType" />
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="blockID" type="xs:int" use="optional"/>
    </xs:complexType>

    <xs:simpleType name="sempromState">
        <xs:restriction base="xs:string">
            <xs:enumeration value="not_specified" />
            <xs:enumeration value="active" />
            <xs:enumeration value="deactivated" />
        </xs:restriction>
    </xs:simpleType>

    <xs:simpleType name="relationType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="not_specified" />
            <xs:enumeration value="has_part" />
            <xs:enumeration value="part_of" />
            <xs:enumeration value="connected_to" />
            <xs:enumeration value="stored_in" />
            <xs:enumeration value="custom" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

Attributes Block

The XML binding for the Attributes block follows the same requirements as in the binary format specification: Each such block has to declare a name space and can contain zero to many non-standard attributes, each of which has to occur at most once.

Additionally to the pure content of the block data the schema file declares an optional attribute blockID which can be used to put the information into context. It may be omitted if only the content is relevant.

attributesBlockData.xsd

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/attributes#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://semprom.de/attributes#">

    <xs:element name="attributesBlockData" type="tns:attributesBlockType" />

    <xs:complexType name="attributesBlockType">
        <xs:sequence>
            <xs:element name="namespace" type="xs:string" />
            <xs:element name="attribute" minOccurs="0" maxOccurs="unbounded">
                <xs:complexType>
                    <xs:simpleContent>
                        <xs:extension base="xs:string">
                            <xs:attribute name="key" type="xs:string" />
                        </xs:extension>
                    </xs:simpleContent>
                </xs:complexType>
            </xs:element>
        </xs:sequence>
        <xs:attribute name="blockID" type="xs:int" use="optional" />
    </xs:complexType>
</xs:schema>

Block Meta Data

The XML binding for the block meta data contains most of the information contained in the SemProM block header as in binary format specification. The difference is that address information are omitted because they are not needed in XML format. Additionally to the pure content of the block meta data the schema file declares an optional attribute blockID which can be used to put the information into context. It may be omitted if only the content is relevant.

The encoding of several fields is worth of a discussion. For the sake of simplicity fields like ‘contentType’ or the keys and values of the meta tags are currently encoded using the numeric values as declared in SemProM binary format specification v1.0. The fields ‘creator’ and ‘lastModifier’ are currently encoded as Base64 string of the binary representation to reflect the same encoding as in the binary format.

blockMeta.xsd

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/blockmeta#" 
    xmlns:tns="http://semprom.de/blockmeta#"
    xmlns:xs="http://www.w3.org/2001/XMLSchema">

    <xs:element name="blockMeta" type="tns:blockMetaType" />

    <xs:complexType name="blockMetaType">
       <xs:all>
          <xs:element name="blockType" type="tns:blockType" minOccurs="1" maxOccurs="1" />
          <xs:element name="contentType" type="xs:int" minOccurs="1" maxOccurs="1" />
          <xs:element name="metaTags" type="tns:metaTags" minOccurs="0" maxOccurs="1" />
          <xs:element name="creationTimestamp" type="xs:long" minOccurs="0" maxOccurs="1" />
          <xs:element name="creatorType" type="tns:authorType" minOccurs="1" maxOccurs="1" />
          <xs:element name="creator" type="xs:base64Binary" minOccurs="0" maxOccurs="1" />
          <xs:element name="lastModifiedTimestamp" type="xs:long" minOccurs="0" maxOccurs="1"/>
          <xs:element name="lastModifierType" type="tns:authorType" minOccurs="0" maxOccurs="1"/>
          <xs:element name="lastModifier" type="xs:base64Binary" minOccurs="0" maxOccurs="1" />
          <xs:element name="signatureType" minOccurs="1" maxOccurs="1">
              <xs:simpleType>
                  <xs:restriction base="xs:string">
                      <xs:enumeration value="None" />
                      <xs:enumeration value="SHA1RSA" />
                  </xs:restriction>
              </xs:simpleType>
          </xs:element>
       </xs:all>
       <xs:attribute name="blockID" type="xs:int" use="optional" />
    </xs:complexType>

    <xs:simpleType name="blockType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="None" />
            <xs:enumeration value="Ids" />
            <xs:enumeration value="Core" />
            <xs:enumeration value="Structure" />
            <xs:enumeration value="SemProm" />
            <xs:enumeration value="Attributes" />
            <xs:enumeration value="Custom" />
        </xs:restriction>
    </xs:simpleType>

    <xs:complexType name="metaTags">
        <xs:all>
            <xs:element name="productLifeCycle" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="6" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="verticalMarket" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="9" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="userRole" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="3" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="importance" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="255" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="flags" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="3" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
            <xs:element name="language" minOccurs="0" maxOccurs="1">
                <xs:simpleType>
                    <xs:restriction base="xs:int">
                        <xs:minInclusive value="1" />
                        <xs:maxInclusive value="139" />
                    </xs:restriction>
                </xs:simpleType>
            </xs:element>
        </xs:all>
    </xs:complexType>

    <xs:simpleType name="authorType">
        <xs:restriction base="xs:string">
            <xs:enumeration value="None" />
            <xs:enumeration value="DUNS" />
            <xs:enumeration value="GLN" />
            <xs:enumeration value="EMAIL" />
            <xs:enumeration value="OpenId" />
            <xs:enumeration value="Custom" />
        </xs:restriction>
    </xs:simpleType>
</xs:schema>

XML encoding of a SemProM

The XML encoding of a SemProM has exactly one tag metas containing all the block meta data according to blockMeta.xsd as well as exactly one tag blocks containing all the block data according to the block data XML schemata. To represent a SemProM correctly, all of the block meta data and block data encodings have to declare the attribute blockID.

The schema file declares also an optional attribute blockID which is only of importance when encoding SemProM block data of block type "SemProm". The attribute version is optional and of more importance if a later version of the SemProM specification occurs. If it is omitted, the value of "1.0" is assumed.

semprom.xsd

<?xml version="1.0"?>
<xs:schema targetNamespace="http://semprom.de/semprom#" 
    xmlns:xs="http://www.w3.org/2001/XMLSchema"
    xmlns:tns="http://semprom.de/semprom#"
    xmlns:spmid="http://semprom.de/ids#"
    xmlns:spmcore="http://semprom.de/core#"
    xmlns:spmstruct="http://semprom.de/structure#"
    xmlns:spmatt="http://semprom.de/attributes#"
    xmlns:spmbm="http://semprom.de/blockmeta#" >

  <xs:import namespace="http://semprom.de/ids#" schemaLocation="idsBlockData.xsd" />
  <xs:import namespace="http://semprom.de/core#" schemaLocation="coreBlockData.xsd" />
  <xs:import namespace="http://semprom.de/structure#" schemaLocation="structureBlockData.xsd"/>
  <xs:import namespace="http://semprom.de/attributes#" schemaLocation="attributesBlockData.xsd"/>
  <xs:import namespace="http://semprom.de/blockmeta#" schemaLocation="blockMeta.xsd" />

  <xs:element name="semprom" type="tns:sempromType" />

  <xs:complexType name="sempromType">
      <xs:sequence>
          <xs:element name="metas" minOccurs="1" maxOccurs="1">
              <xs:complexType>
                  <xs:sequence>
                      <xs:element name="blockMeta" type="spmbm:blockMetaType"
                          minOccurs="0" maxOccurs="unbounded"/>
                  </xs:sequence>
              </xs:complexType>
          </xs:element>
          <xs:element name="blocks" minOccurs="1" maxOccurs="1">
              <xs:complexType>
                  <xs:choice minOccurs="0" maxOccurs="unbounded">
                      <xs:element name="idsBlockData" type="spmid:idsBlockType"
                          minOccurs="0" maxOccurs="1"/>
                      <xs:element name="coreBlockData" type="spmcore:coreBlockType"
                          minOccurs="0" maxOccurs="1"/>
                      <xs:element name="structureBlockData" type="spmstruct:structureBlockType"
                          minOccurs="0" maxOccurs="1"/>
                      <xs:element name="attributesBlockData" type="spmatt:attributesBlockType"
                          minOccurs="0" maxOccurs="unbounded"/>
                      <xs:element name="sempromBlockData" type="tns:sempromType"
                          minOccurs="0" maxOccurs="unbounded"/>
                  </xs:choice>
              </xs:complexType>
          </xs:element>
      </xs:sequence>
      <xs:attribute name="blockID" type="xs:int" use="optional" />
      <xs:attribute name="version" type="xs:string" default="1.0" />    
  </xs:complexType>
</xs:schema>

Example

This is an example XML of a SemProM with four blocks each of which contains some (fake) data.

<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<semprom version="1.0" xmlns="http://semprom.de/semprom#">
    <metas>
        <blockMeta blockID="0">
            <blockType>Core</blockType>
            <contentType>106</contentType>
            <creationTimestamp>1291716162</creationTimestamp>
            <creatorType>None</creatorType>
            <creator />
            <signatureType>None</signatureType>
        </blockMeta>
        <blockMeta blockID="1">
            <blockType>Ids</blockType>
            <contentType>106</contentType>
            <creationTimestamp>1291716162</creationTimestamp>
            <creatorType>None</creatorType>
            <creator />
            <signatureType>None</signatureType>
        </blockMeta>
        <blockMeta blockID="2">
            <blockType>Structure</blockType>
            <contentType>106</contentType>
            <creationTimestamp>1291716162</creationTimestamp>
            <creatorType>None</creatorType>
            <creator />
            <signatureType>None</signatureType>
        </blockMeta>
        <blockMeta blockID="3">
            <blockType>Attributes</blockType>
            <contentType>106</contentType>
            <creationTimestamp>1291716162</creationTimestamp>
            <creatorType>None</creatorType>
            <creator />
            <signatureType>None</signatureType>
        </blockMeta>
    </metas>
    <blocks>
        <coreBlockData blockID="0">
            <version>1.0</version>
            <product_name>prodname</product_name>
            <company_name>sap</company_name>
        </coreBlockData>
        <idsBlockData blockID="1">
            <primaryID idType="ipv4">fwAAAQ==</primaryID>
        </idsBlockData>
        <structureBlockData blockID="2">
            <state>active</state>
            <record recordType="connected_to">
                <primaryID idType="uri">my.uri:bla</primaryID>
            </record>
        </structureBlockData>
        <attributesBlockData blockID="3">
            <namespace>test.namespace</namespace>
            <attribute key="att1">the value</attribute>
        </attributesBlockData>
    </blocks>
</semprom>