Skip to content

Node Types in @context #76

@AtesComp

Description

@AtesComp

So, reading the specification, I see the the line:
"Specifically, @type cannot be used in a context to define a node's type."
where I ask, WTF? Why not? Why so short-sighted? Why do node types need to be red-headed stepchildren?

Given conversions from JSON to JSON-LD , it would be extremely useful to apply type (coercion) to IRIs and blank nodes via @context. Example:

Given

{
  "type": "indicator",
  "id": "indicator--e2e1a340-4415-4ba8-9671-f7343fbf0836",
  "external_references": [
    {
      "source_name": "veris",
      "external_id": "0001AA7F-C601-424A-B2B8-BE6C9F5164E7",
      "url": "https://github.com/vz-risk/VCDB/blob/master/data/json/0001AA7F-C601-424A-B2B8-BE6C9F5164E7.json"
    }
  ]
}

I can header the data with a context:

  "@context": {
    "@version": 1.1,
    "@base": "http://purl.org/cyber/stix/identifier/",
    "@vocab": "http://purl.org/cyber/stix/vocab/",

    "stix": "http://purl.org/cyber/stix#",
    "id": "@id",
    "type": "@type",
    "indicator": "stix:Indicator",
    "external_references": {
      "@type": "@id",
      "@context": {
        "url": { "@type": "@id" }
      }
    }
  },

which converts the data somewhat nicely. Pop it into the JSON-LD 1.1 Playground and view the table. I've severely limited the example for clarity.

Generally the properties "external_references", "url", and others would have ontology definitions to cast the un-typed nodes. However, this is not always the case. As an example, let's assume "external_references" does not cast to a single definitive node type. The "external_references" structure will produce a blank node without type. We have applications where a property key name may be used in different contexts (thanks for scoped @context !!!) and therefore may indicate different node types. An ontology can define multiple types for a given property, but its not definitive. The data may specify the definitive node type by context. Without a method to type nodes in context, the specification severely limits the usefulness of the conversion.

SUGGESTION:

Since "@type" allows for all manner of data typing, why not allow "@type" to also provide node typing. It seems a simple addition to the specification, such as:

  "@type": { "@id": "http://my.friggin.org/has/class" }

where we specify the context is a node, as before, with the addition of the node type(s) [sure, more than one node type using "@id": { "nt1", "nt2" } or maybe multiple "@type" statements, why not?]. I'm not saying we NEED multiple types for the specification. Allowing for just one node type would be monumental. In fact,

  "@type": { "http://my.friggin.org/has/class" }

might be enough or a short form as it might imply "@id". Or maybe add a specification for value types as well (just to be thoughtful about values):

  "@type": { "@value": "http://my.friggin.org/has/valueType" }

Ahh, uniformity! So, here are the different context types:

  "@type": valuetype
  "@type": { "@value": valuetype }
  "@type": "@id"
  "@type": { "@id": nodetype }

NOTE: There was some discussion about allowing the value to be both a node type and a data type. There is something very wrong about that kind of data pattern.

The above context would be modified as follows:

  "@context": {
    "@version": 1.1,
    "@base": "http://purl.org/cyber/stix/identifier/",
    "@vocab": "http://purl.org/cyber/stix/vocab/",

    "stix": "http://purl.org/cyber/stix#",
    "id": "@id",
    "type": "@type",
    "indicator": "stix:Indicator",
    "external_references": {
      "@type": { "@id": "stix:ExternalReference" },
      "@context": {
        "url": { "@type": {"@id": "stix:URL"} }
      }
    }
  },

Now, I could query for all things "stix:ExternalReference" or "stix:URL" without resorting to a bastardized conversion therapy.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions