Problem/Motivation
Drupal wants to use JSON-LD to send messages between the dev and live instances of a site, but also to communicate with outside parties. When communicating with outside parties, a Drupal site would use a vocabulary such as Schema.org, which provides a domain model which basically follows RDF vocabulary common practice. However, some Drupal field types are modeled in a unusual way, which would mean that the external consumer could not use the data.
The full Drupal domain model will be supported in one version of the JSON-LD serialization. However, we want another version of JSON-LD that can be used by outside consumers, and we need a way to map to the outside consumers' domain model.
Literal fields don't match
The Entity API handles literal field values in a way that is inconsistent with common practice for most RDF-ish domain models.
Drupal body field
Schema.org
In the Drupal version, there is an intermediary structure (called a 'blank node' in RDF) for tying all of the related values (value, summary, format) together. For field types such as text and numbers, using a blank node is a unusual way to model the field.
In addition, some fields contain information that is more like configuration (e.g. the format). Most RDF domain models that Drupal sites would want to use do not include this information about literals, or would include it as datatype information.
Other fields DO match
However, for some field types, using an intermediary node does match the RDF way of modeling. An example of such a field is Addressfield.
Drupal Addressfield
Schema.org
Proposed resolution
Microdata module has a way of handling this.
The use of an intermediary blank node can be toggled on and off on a field-by-field basis, using an '#is_item' flag. For example, the '#is_item' flag would be TRUE for the Addressfield, as shown above. If the '#is_item' flag is false, the field properties are directly related to the parent entity, as in the case of the body and summary.
In Microdata module, each field property has to assert that it supports microdata. For example, the 'value' and 'summary' properties of the body field support microdata, but the 'format' does not. This feature from microdata isn't as necessary, since a user could just leave the mapping empty for unwanted field properties.
Comment | File | Size | Author |
---|---|---|---|
#1 | 1813328-literal-handling__for-testing.patch | 23.36 KB | linclark |
#1 | 1813328-literal-handling__for-review.txt | 2.45 KB | linclark |
schemaorg-addressfield.png | 78.72 KB | linclark | |
drupal-addressfield.png | 67.2 KB | linclark | |
schemaorg-literal-body.png | 45.38 KB | linclark |
Comments
Comment #1
Anonymous (not verified) CreditAttribution: Anonymous commentedI'm attaching a patch for testing that produces the following JSON-LD output. I've removed language handling to make the data model difference clear.
The patch for review shows the changes to rdf.module and system.module that enable this. It is unlikely that this is the way we want to do it, but I just wanted to post something that we could start talking about.
Comment #3
Anonymous (not verified) CreditAttribution: Anonymous commentedI used the word standard where, for clarity's sake, I really should use common.
Comment #3.0
Anonymous (not verified) CreditAttribution: Anonymous commentedClarified that this isn't a non-standard, but rather an unusual way to model fields.
Comment #4
scor CreditAttribution: scor commentedThis issue is outdated now that JSON-LD is no longer in core. The is handled at the field formatter level in RDFa.