TOGoS Binary Blocks

Is a simple, extensible, and compact way to associate arbitrarily encoded objects with encoding information.

A TBB packet is encoded as follows:

The TBB format does not provide any way to indicate the length or checksum of the packet; that is left to the container (such as a UDP packet, a file, a database record, etc).

Schema schema

A schema should indicate a format for the payload and a prototype. How to interpret these properties is up to the application, and they can be either rdf:resource links or inline RDF+XML. It's expected that format will often be an opaque resource URI identifying a predefined format, but it may also point to a machine-readable format description (such as ASN.1 encoding rules), or simply be a block of human-readable text describing the format.

As an example, say there are QQ objects to be described (nevermind what a QQ represents) that have, among other properties, foofiness and color, and that 23 and purple are such common values for those properties that we don't want to repeat them in each serialization of a QQ object. In that case, the schema might be:

<Schema xmlns="http://ns.nuke24.net/TBB/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
    <format rdf:resource="http://example.com/QQ/CompactQFormat1"/>
    <prototype>
        <qq:QQObject xmlns:qq="http://example.com/QQ/">
            <qq:foofiness>23</qq:foofiness>
            <qq:color>purple</qq:color>
        </qq:QQObject>
    </prototype>
</Schema>

In addition to format and prototype, a schema may specify other, format-specific information. When represented as RDF, format-specific properties should be namespaced appropriately (not in the http://ns.nuke24.net/TBB/ namespace).

As an alternative to RDF+XML, the schema itself may be encoded in the TBB format, or any other encoding, so long as it's distinguishable and understood by the target application.

Applications whose objects have only a few predetermined schemas may have interpreters pre-loaded, so that they do not need to load schemas at all, but simply look them up by their hash. For future compatibility, those hashes should still be based on RDF+XML documents that actually describe the schemas.

Fetching schemas

How to go about this is left completely up to the application. Since the SHA-1 sum of the schema is known, you are free to fetch it from untrusted sources. Since many objects will share a single schema, and because schemas are uniquely identified by their hash, applications can easily cache an efficient representation.