Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Framing returns a blank @graph. #30

Closed
workergnome opened this issue Oct 10, 2016 · 3 comments
Closed

Framing returns a blank @graph. #30

workergnome opened this issue Oct 10, 2016 · 3 comments
Assignees
Labels

Comments

@workergnome
Copy link
Contributor

When I try and frame a document, I'm getting a blank graph returned.

require 'linkeddata'

unframed_json = JSON.parse '[
  {
    "@id": "http://vocab.getty.edu/ulan/500115403",
    "http://xmlns.com/foaf/0.1/focus": [
      {
        "@id": "http://vocab.getty.edu/ulan/500115403-agent"
      }
    ],
    "http://www.w3.org/2004/02/skos/core#prefLabel": [
      {
        "@value": "Couture, Thomas"
      }
    ],
    "http://www.w3.org/2004/02/skos/core#inScheme": [
      {
        "@id": "http://vocab.getty.edu/ulan/"
      }
    ],
    "http://schema.org/url": [
      {
        "@id": "http://www.getty.edu/vow/ULANFullDisplay?find=&role=&nation=&subjectid=500115403"
      }
    ]
  }
]'

frame = JSON.parse '{
  "@explicit": true,
  "@context": {
    "skos": "http://www.w3.org/2004/02/skos/core#",
    "foaf": "http://xmlns.com/foaf/0.1/",
    "schema": "http://schema.org/",
    "label": "skos:prefLabel",
    "id": "@id",
    "source": {
      "@id": "skos:inScheme",
      "@type": "@id"
    },
    "agent": {
      "@id": "foaf:focus",
      "@type": "@id"
    },
    "website": {
      "@id": "schema:url",
      "@type": "@id"
    }
  },
  "label": {},
  "id": {},
  "source": {},
  "agent": {},
  "website": {}
}'

puts JSON::LD::API.frame(unframed_json, frame)

returns

{
 "@context"=>{
  "skos"=>"http://www.w3.org/2004/02/skos/core#", 
  "foaf"=>"http://xmlns.com/foaf/0.1/", 
  "schema"=>"http://schema.org/", 
  "label"=>"skos:prefLabel", 
  "id"=>"@id",
   "source"=>{"@id"=>"skos:inScheme", "@type"=>"@id"}, 
   "agent"=>{"@id"=>"foaf:focus", "@type"=>"@id"}, 
   "website"=>{"@id"=>"schema:url", "@type"=>"@id"}
 }, 
 "@graph"=>[]
}

But when I put the same JSON into the JSON-LD Playground, I get the values I expect:

permalink to Playground

@gkellogg
Copy link
Member

It looks like there's a difference in the implementations when @id is included in the frame. In your example, if you remove "id": {},, you should get the output you expect.

In the current draft, the behavior of @id is undefined. However, in a branch being considered to be merged (which you can see here), it is expected to be one or more IRI or BNodes, which are used to match. However, it seems consistent with other matching to interpret {} as a wild-card, so this is likely a bug in both the new spec and my implementation.

In the mean time, try just removing id from the frame.

@gkellogg gkellogg added the bug label Oct 13, 2016
@gkellogg gkellogg self-assigned this Oct 13, 2016
@workergnome
Copy link
Contributor Author

Thank you. That appears to be exactly what is going on, and your work-around solves my immediate problem.

@gkellogg
Copy link
Member

This should be fully supported now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants