-
Notifications
You must be signed in to change notification settings - Fork 71
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
Triples not loaded when using @context and @graph #40
Comments
I tried parsing the rdfa using rdflib, and then serializing with json-ld. import rdflib
g = rdflib.Graph()
g.load("input.rdfa", format="rdfa")
with open("output.jsonld", "w") as fp:
fp.write(g.serialize(format="json-ld", indent=4)) cat output.jsonld [
{
"@id": "http://schema.org/CreativeWork",
"@type": [
"http://www.w3.org/2000/01/rdf-schema#Class"
],
"http://purl.org/dc/terms/source": [
{
"@id": "http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_rNews"
}
],
"http://www.w3.org/2000/01/rdf-schema#comment": [
{
"@value": "The most generic kind of creative work, including books, movies, photographs, software programs, etc."
}
],
"http://www.w3.org/2000/01/rdf-schema#label": [
{
"@value": "CreativeWork"
}
],
"http://www.w3.org/2000/01/rdf-schema#subClassOf": [
{
"@id": "http://schema.org/Thing"
}
]
},
{
"@id": "http://schema.org/WebPage",
"@type": [
"http://www.w3.org/2000/01/rdf-schema#Class"
],
"http://www.w3.org/2000/01/rdf-schema#comment": [
{
"@value": "A web page. Every web page is implicitly assumed to be declared to be of type WebPage, so the various properties about that webpage, such as <code>breadcrumb</code> may be used. We recommend explicit declaration if these properties are specified, but if they are found outside of an itemscope, they will be assumed to be about the page."
}
],
"http://www.w3.org/2000/01/rdf-schema#label": [
{
"@value": "WebPage"
}
],
"http://www.w3.org/2000/01/rdf-schema#subClassOf": [
{
"@id": "http://schema.org/CreativeWork"
}
]
}
] Parsing the above |
When defining the context somewhere else, and specifying it in each of the objects in the list using [
{
"@context": "schema.context",
"@id": "schema:CreativeWork",
"@type": "rdfs:Class",
"dcterms:source": {
"@id": "http://www.w3.org/wiki/WebSchemas/SchemaDotOrgSources#source_rNews"
},
"rdfs:comment": "The most generic kind of creative work, including books, movies, photographs, software programs, etc.",
"rdfs:label": "CreativeWork",
"rdfs:subClassOf": {
"@id": "schema:Thing"
}
},
{
"@context": "schema.context",
"@id": "schema:WebPage",
"@type": "rdfs:Class",
"rdfs:comment": "A web page. Every web page is implicitly assumed to be declared to be of type WebPage, so the various properties about that webpage, such as <code>breadcrumb</code> may be used. We recommend explicit declaration if these properties are specified, but if they are found outside of an itemscope, they will be assumed to be about the page.",
"rdfs:label": "WebPage",
"rdfs:subClassOf": {
"@id": "schema:CreativeWork"
}
}
] How can I avoid writing |
Similar problem here also. Cannot parse back the serialized json-ld (serialized by rdflib-jsonld). |
It seems to work when using ConjunctiveGraph instead of Graph. |
@fserena |
Example 61 from https://www.w3.org/TR/json-ld/ gives an empty graph for me, even with |
#53 seems to be the same issue. The suggested fix from @niklasl there also uses ConjunctiveGraph but is not working for me. See also RDFLib/rdflib#436 |
Maybe this helps: I got it working, only when I stopped using the method-result chaining shortcut syntax:
This works. However the object "bar" returned from calling 'parse' is the wrong/empty graph, so we can't chain the expressions together with ConjunctiveGraph().parse(etc...). |
- This will likely be a case that impacts anticipated usage.
Thanks, It's work fine for me! Don't use the chain expressions together with ConjunctiveGraph().parse(etc...). |
I tried converting the following rdfa to jsonld on rdf translator.
The result was the following -
However, when I try to load this json-ld using the following
The text was updated successfully, but these errors were encountered: