Skip to content

Framing: expected behavior for @explicit/@embed/@default #641

Closed
@pjohnston-wiley

Description

@pjohnston-wiley

Apologies in advance if this turns out to be covered by the spec, but i was unable to determine it from the latest draft or the issues on github. In summary, I am trying to understand how the various switches in framing can be used at different levels to control output, in particular how @explicit and @embed are supposed to interact with each other. I appear to be running into some inconsistencies, and I would just like to understand if these are just bugs in the current implementation, or i am missing the intent. Thanks for your patience.

I have been mostly testing with pyld (i have large files to process, and i would be happy to have a go at fixing it there), though i can reproduce the behavior in both the dev and stable playgrounds. This example isolates the behavior.

In expanded form, it looks like this (minus the context):

{
  "@context": {...},
  "@graph": [
      {
          "label": "Some property.",
          "@id": "ex:knows",
          "@type": "ObjectProperty",
          "domain": "ex:Flinstone", 
          "range": "_:1"
      },
      {
          "label": "Rubble class.",
          "@id": "ex:Rubble",
	  "@type": "Class",
	  "termStatus": "stable"
      },
      {
          "label": "Flintstone class.",
          "@id": "ex:Flintstone",
	  "@type": "Class"
      },
      {
          "@id": "_:1",
          "@type": "Class",
          "unionOf": {
              "@list": [
                  {
                      "@id": "ex:Flintstone"
                  },
                  {
                      "@id": "ex:Rubble"
                  }
              ]
          }
      }			
  ]
}

By way of context, the exercise is rendering OWL ontologies in a framed form to be used to build documentation. The case to examine here is that the domain and range of a property can be either a single Class or a union of classes. The latter manifests as a blank node with a unionOf property with an ordered list of class ids. In English terms, here i am saying that Flintstones can know either other Flintstones, or Rubbles.

In order to deal with this scenario, my frame domain and range are identical, and look like this:

			"range": {
				"@default": "Thing",
				"@explicit": true,
				"@embed": "@always",
				"unionOf": {
					"@embed": "@never"
				}
			},

with the intent being that if the property (1) references just a single class, it will look like:

"range": "ex:Flintstone",

if it (2) references a union of classes it will look like:

"range": {"unionOf": ["ex:Flintstone", "ex:Rubble"]},

and (3) if the property is absent it will have a range of all possible classes:

"range": "Thing",

What i am seeing in the link above is that case (2) and (3) work fine, but case (1) fails and renders the default (3).

Is this expected behavior?

By way of comparison, if i set:

			"range": {
				"@default": "Thing",
				"@explicit": false,
				"@embed": "@always"
			},

but that gives me a lot of unwanted information (as in other properties on the class i had wanted to omit), and i then cannot control the output of the unionOf statement (see here):

      "domain": "ex:Flinstone",
      "range": {
        "@id": "_:b0",
        "@type": "Class",
        "unionOf": [
          {
            "@id": "ex:Flintstone",
            "@type": "Class",
            "label": "Flintstone class."
          },
          {
            "@id": "ex:Rubble",
            "@type": "Class",
            "termStatus": "stable",
            "label": "Rubble class."
          }
        ]
      },

There does appear to be a bug if the JSON-LD @type is @vocab and the property is absent, the defaulting mechanism renders incorrectly, compare ex:termStatus with ex:supersedes in the referenced example - it renders ex:termStatus rather than the alias termStatus. I suspect framing is compacting the output prior to defaulting.

Regards,
Patrick Johnston

Metadata

Metadata

Assignees

No one assigned

    Labels

    deferIssue deferred to future Working Groupframing

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions