diff --git a/Gemfile.lock b/Gemfile.lock index 068827f5..eb1d33cb 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -9,8 +9,8 @@ GEM colorize (0.8.1) concurrent-ruby (1.0.5) connection_pool (2.2.2) - ebnf (1.1.2) - rdf (>= 2.2, < 4.0) + ebnf (1.1.3) + rdf (~> 3.0) sxp (~> 1.0) equivalent-xml (0.6.0) nokogiri (>= 1.4.3) @@ -22,11 +22,11 @@ GEM htmlentities (4.3.4) i18n (1.1.0) concurrent-ruby (~> 1.0) - json-ld (3.0.0) + json-ld (3.0.1) multi_json (~> 1.12) rdf (>= 2.2.8, < 4.0) - json-ld-preloaded (3.0.0) - json-ld (>= 2.2, < 4.0) + json-ld-preloaded (3.0.1) + json-ld (~> 3.0) multi_json (~> 1.12) rdf (~> 3.0) ld-patch (0.3.3) @@ -71,7 +71,7 @@ GEM nokogiri public_suffix (3.0.3) rake (12.3.1) - rdf (3.0.2) + rdf (3.0.3) hamster (~> 3.0) link_header (~> 0.0, >= 0.0.8) rdf-aggregate-repo (2.2.1) @@ -85,7 +85,7 @@ GEM nokogiri (~> 1.8) rdf (>= 2.2.8, < 4.0) rdf-xsd (>= 2.2, < 4.0) - rdf-n3 (3.0.0) + rdf-n3 (3.0.1) rdf (~> 3.0) rdf-normalize (0.3.3) rdf (>= 2.2, < 4.0) @@ -111,18 +111,18 @@ GEM rdf (>= 2.2, < 4.0) rdf-vocab (>= 2.2, < 4.0) rdf-xsd (>= 2.2, < 4.0) - rdf-trig (2.2.0) - ebnf (~> 1.0, >= 1.0.1) - rdf (>= 2.2, < 4.0) - rdf-turtle (>= 2.2, < 4.0) + rdf-trig (3.0.0) + ebnf (~> 1.1) + rdf (~> 3.0) + rdf-turtle (~> 3.0, >= 3.0.2) rdf-trix (2.2.1) rdf (>= 2.2, < 4.0) - rdf-turtle (3.0.1) + rdf-turtle (3.0.2) ebnf (~> 1.1) rdf (~> 3.0) rdf-vocab (3.0.3) rdf (~> 3.0) - rdf-xsd (3.0.0) + rdf-xsd (3.0.1) rdf (~> 3.0) shex (0.5.2) ebnf (~> 1.1) @@ -132,7 +132,7 @@ GEM rdf-xsd (>= 2.2, < 4.0) sparql (>= 2.2, < 4.0) sxp (~> 1.0) - sparql (3.0.1) + sparql (3.0.2) builder (~> 3.2) ebnf (~> 1.1) rdf (~> 3.0) @@ -158,4 +158,4 @@ DEPENDENCIES rake BUNDLED WITH - 1.16.1 + 1.16.4 diff --git a/Rakefile b/Rakefile index 053ed420..acf44fd8 100644 --- a/Rakefile +++ b/Rakefile @@ -7,6 +7,6 @@ end desc "Extract Examples" task :examples do - sh %(rm -rf examples yaml trig) - sh %(bundle exec common/extract-examples.rb --example-dir examples --yaml-dir yaml --trig-dir trig index.html) + sh %(rm -rf examples yaml) + sh %(bundle exec common/extract-examples.rb --example-dir examples --yaml-dir yaml index.html) end diff --git a/common/common.js b/common/common.js index f9931af9..20e67a7c 100644 --- a/common/common.js +++ b/common/common.js @@ -43,9 +43,9 @@ function restrictReferences(utils, content) { // class 'termlist', and if the target of that reference is // also within a 'dl' element of class 'termlist', then // consider it an internal reference and ignore it. -require(["core/pubsubhub"], function(respecEvents) { +require(["core/pubsubhub"], (respecEvents) => { "use strict"; - respecEvents.sub('end', function(message) { + respecEvents.sub('end', (message) => { if (message === 'core/link-to-dfn') { // all definitions are linked; find any internal references const internalTerms = document.querySelectorAll(".termlist a.internalDFN"); @@ -69,7 +69,7 @@ require(["core/pubsubhub"], function(respecEvents) { // clearRefs is recursive. Walk down the tree of // references to ensure that all references are resolved. - const clearRefs = function(theTerm) { + const clearRefs = (theTerm) => { if (termsReferencedByTerms[theTerm] ) { for (const item of termsReferencedByTerms[theTerm]) { if (termNames[item]) { @@ -142,10 +142,10 @@ require(["core/pubsubhub"], function(respecEvents) { * use include the github.io address (as it should...) * */ -require(["core/pubsubhub"], function(respecEvents) { +require(["core/pubsubhub"], (respecEvents) => { "use strict"; - respecEvents.sub('beforesave', function(documentElement) { - $("a[href]", documentElement).each( function(index) { + respecEvents.sub('beforesave', (documentElement) => { + $("a[href]", documentElement).each((index) => { // Don't rewrite these. if ($(this, documentElement).closest('dd').prev().text().match(/Latest editor|Test suite|Implementation report/)) return; if ($(this, documentElement).closest('section.preserve').length > 0) return; @@ -165,6 +165,24 @@ require(["core/pubsubhub"], function(respecEvents) { }); }); +/* +* Implement tabbed examples. +*/ +require(["core/pubsubhub"], (respecEvents) => { + "use strict"; + respecEvents.sub('end-all', (documentElement) => { + for (const button of document.querySelectorAll(".ds-selector-tabs .selectors button")) { + button.onclick = () => { + const ex = button.closest(".ds-selector-tabs"); + ex.querySelector("button.selected").classList.remove("selected"); + ex.querySelector(".selected").classList.remove("selected"); + button.classList.add('selected'); + ex.querySelector("." + button.dataset.selects).classList.add("selected"); + } + } + }); +}); + function _esc(s) { return s.replace(/&/g,'&') .replace(/>/g,'>') @@ -172,9 +190,20 @@ function _esc(s) { .replace(/ s.trim()).map(s => s.search(/[^\s]/)); + const leastIndent = Math.min(...indents); + return lines.map(s => s.slice(leastIndent)).join("\n"); +} + function updateExample(doc, content) { // perform transformations to make it render and prettier - return _esc(unComment(doc, content)) + return _esc(reindent(unComment(doc, content))) .replace(/\*\*\*\*([^*]*)\*\*\*\*/g, '$1') .replace(/####([^#]*)####/g, '$1'); } @@ -182,6 +211,9 @@ function updateExample(doc, content) { function unComment(doc, content) { // perform transformations to make it render and prettier - return content.replace(//, ''); + return content + .replace(//, '') + .replace(/< !--/g, ''); } diff --git a/common/extract-examples.rb b/common/extract-examples.rb index 495c9b9f..e6fe272f 100755 --- a/common/extract-examples.rb +++ b/common/extract-examples.rb @@ -26,12 +26,11 @@ schema: "http://schema.org/", xsd: "http://www.w3.org/2001/XMLSchema#" } -example_dir = yaml_dir = trig_dir = verbose = number = nil +example_dir = yaml_dir = verbose = number = nil opts = GetoptLong.new( ["--example-dir", GetoptLong::REQUIRED_ARGUMENT], ["--yaml-dir", GetoptLong::REQUIRED_ARGUMENT], - ["--trig-dir", GetoptLong::REQUIRED_ARGUMENT], ["--verbose", '-v', GetoptLong::NO_ARGUMENT], ["--number", '-n', GetoptLong::REQUIRED_ARGUMENT], ) @@ -39,7 +38,6 @@ case opt when '--example-dir' then example_dir = arg && FileUtils::mkdir_p(arg) when '--yaml-dir' then yaml_dir = arg && FileUtils::mkdir_p(arg) - when '--trig-dir' then trig_dir = arg && FileUtils::mkdir_p(arg) when '--verbose' then verbose = true when '--number' then number = arg.to_i end @@ -66,6 +64,119 @@ def justify(str) lines.map {|s| s[leading..-1]}.join("\n") end +def table_to_dataset(table) + repo = RDF::Repository.new + titles = table.xpath('thead/tr/th/text()').map(&:to_s) + + table.xpath('tbody/tr').each do |row| + gname, subject, predicate, object = nil + row.xpath('td/text()').map(&:to_s).each_with_index do |cell, ndx| + case titles[ndx] + when 'Graph' + gname = case cell + when nil, '', " " then nil + when /^_:/ then RDF::Node.intern(cell[2..-1]) + else RDF::Vocabulary.expand_pname(cell) + end + when 'Subject' + subject = case cell + when /^_:/ then RDF::Node.intern(cell[2..-1]) + else RDF::Vocabulary.expand_pname(cell) + end + when 'Property' + predicate = RDF::Vocabulary.expand_pname(cell) + when 'Value' + object = case cell + when /^_:/ then RDF::Node.intern(cell[2..-1]) + when /^\w+:/ then RDF::Vocabulary.expand_pname(cell) + else RDF::Literal(cell) + end + when 'Value Type' + case cell + when /IRI/, '-', /^\s*$/, " " + else + # We might think something was an IRI, but determine that it's not + object = RDF::Literal(object.to_s) unless object.literal? + object.datatype = RDF::Vocabulary.expand_pname(cell) + end + when 'Language' + case cell + when '-', /^\s*$/ + else + # We might think something was an IRI, but determine that it's not + object = RDF::Literal(object.to_s) unless object.literal? + object.datatype = RDF.langString + object.language = cell.to_sym + end + end + end + repo << RDF::Statement.new(subject, predicate, object, graph_name: gname) + end + + repo +end + +def dataset_to_table(repo) + has_graph = !repo.graph_names.empty? + litereals = repo.objects.select(&:literal?) + has_datatype = litereals.any?(&:datatype?) + has_language = litereals.any?(&:language?) + positions = {} + + head = [] + head << "Graph" if has_graph + head += %w(Subject Property Value) + + if has_datatype && has_language + head += ["Value Type", "Language"] + positions = {datatype: (has_graph ? 4 : 3), language: (has_graph ? 5 : 4)} + elsif has_datatype + positions = {datatype: (has_graph ? 4 : 3)} + head << "Value Type" + elsif has_language + positions = {language: (has_graph ? 4 : 3)} + head << "Language" + end + + rows = [] + repo.each_statement do |statement| + row = [] + row << (statement.graph_name || " ").to_s if has_graph + row += statement.to_triple.map do |term| + if term.uri? && RDF::Vocabulary.find_term(term) + RDF::Vocabulary.find_term(term).pname + else + term.to_s + end + end + + if has_datatype + if statement.object.literal? && statement.object.datatype? + row[positions[:datatype]] = RDF::Vocabulary.find_term(statement.object.datatype).pname + else + row[positions[:datatype]] = " " + end + end + + if has_language + if statement.object.literal? && statement.object.language? + row[positions[:language]] = statement.object.language.to_s + else + row[positions[:language]] = " " + end + end + + rows << row + end + + "
#{cell} | "}.join("") + + "
---|
#{cell} | "}.join("") + "
Examples are in light khaki boxes, with khaki left border, and with a numbered "Example" header in khaki. Examples are always informative. - The content of the example is in monospace font and may be syntax colored.+ The content of the example is in monospace font and may be syntax colored. + + Examples may have tabbed navigation buttons to show the results of transforming + an example into other representations. + diff --git a/examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms.jsonld b/examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms-expanded.jsonld similarity index 100% rename from examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms.jsonld rename to examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms-expanded.jsonld diff --git a/examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms-statements.table b/examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms-statements.table new file mode 100644 index 00000000..5eb3a381 --- /dev/null +++ b/examples/example-003-Sample-JSON-LD-document-using-full-IRIs-instead-of-terms-statements.table @@ -0,0 +1,24 @@ +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +schema:image | +http://manu.sporny.org/images/manu.png | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:url | +http://manu.sporny.org/ | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +foaf:name | +Manu Sporny | +
_:b0 | +foaf:homepage | +http://manu.sporny.org/ | +
_:b0 | +foaf:img | +http://manu.sporny.org/images/manu.png | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +schema:image | +http://manu.sporny.org/images/manu.png | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:url | +http://manu.sporny.org/ | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +schema:name | +Manu Sporny | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +schema:url | +http://manu.sporny.org/ | +
Subject | +Property | +Value | +
---|---|---|
http://me.markus-lanthaler.com/ | +schema:name | +Markus Lanthaler | +
Subject | +Property | +Value | +
---|---|---|
http://me.markus-lanthaler.com/ | +rdf:type | +schema:Person | +
http://me.markus-lanthaler.com/ | +schema:givenName | +Markus | +
http://me.markus-lanthaler.com/ | +schema:familyName | +Lanthaler | +
Subject | +Property | +Value | +
---|---|---|
http://me.markus-lanthaler.com/ | +rdf:type | +schema:Person | +
http://me.markus-lanthaler.com/ | +rdf:type | +foaf:Person | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/places#BrewEats | +rdf:type | +schema:Person | +
Subject | +Property | +Value | +
---|---|---|
http://manu.sporny.org/about#manu | +rdf:type | +schema:Person | +
http://manu.sporny.org/about#manu | +schema:name | +Manu Sporny | +
http://manu.sporny.org/about#manu | +schema:knows | +http://greggkellogg.net/foaf#me | +
Subject | +Property | +Value | +
---|---|---|
http://manu.sporny.org/about#manu | +rdf:type | +schema:Person | +
http://manu.sporny.org/about#manu | +schema:name | +Manu Sporny | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
http://manu.sporny.org/about#manu | +schema:knows | +http://greggkellogg.net/foaf#me | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
_:b0 | +foaf:name | +Manu Sporny | ++ |
_:b0 | +foaf:homepage | +http://manu.sporny.org/ | ++ |
_:b0 | +foaf:depiction | +http://twitter.com/account/profile_image/manusporny | ++ |
_:b1 | +dc:title | +The Empire State Building | ++ |
_:b1 | +dc:description | +The Empire State Building is a 102-story landmark in New York City. | ++ |
_:b2 | +geo:lat | +40.75 | +xsd:decimal | +
_:b2 | +geo:long | +73.98 | +xsd:decimal | +
_:b1 | +schema:geo | +_:b2 | ++ |
Subject | +Property | +Value | +
---|---|---|
_:b1 | +http://example.com/organization#name | +Graz University of Technology | +
_:b0 | +http://example.com/person#details | +_:b1 | +
_:b0 | +http://example.com/person#name | +Markus Lanthaler | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
_:b0 | +foaf:name | +Manu Sporny | ++ |
_:b0 | +foaf:homepage | +http://manu.sporny.org/ | +IRI | +
_:b0 | +foaf:depiction | +http://twitter.com/account/profile_image/manusporny | +xsd:string | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/places#BrewEats | +rdf:type | +schema:Restaurant | +
http://example.org/places#BrewEats | +schema:name | +Brew Eats | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/places#BrewEats | +rdf:type | +schema:Restaurant | +
http://example.org/places#BrewEats | +schema:name | +Brew Eats | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/places#BrewEats | +rdf:type | +http://example/document#Restaurant | +
http://example.org/places#BrewEats | +http://example/document#name | +Brew Eats | +
Subject | +Property | +Value | +
---|---|---|
http://example.com/document.jsonld | +rdfs:label | +Just a simple document | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +foaf:Person | +
_:b0 | +foaf:name | +Dave Longley | +
Subject | +Property | +Value | +
---|---|---|
http://me.markus-lanthaler.com/ | +rdf:type | +foaf:Person | +
http://me.markus-lanthaler.com/ | +foaf:name | +Markus Lanthaler | +
http://me.markus-lanthaler.com/ | +foaf:depiction | +http://twitter.com/account/profile_image/markuslanthaler | +
http://me.markus-lanthaler.com/ | +foaf:homepage | +http://www.markus-lanthaler.com/ | +
Subject | +Property | +Value | +
---|---|---|
http://example.com/compact-iris-are-considered | +http://example.com/property | +@prefix does not require a gen-delim | +
_:b0 | +http://example.com/property | +http://example.com/compact-iris-are-considered | +
Subject | +Property | +Value | +
---|---|---|
http://example.com/about#gregg | +rdf:type | +foaf:Person | +
http://example.com/about#gregg | +foaf:name | +Gregg Kellogg | +
Subject | +Property | +Value | +
---|---|---|
https://www.w3.org/TR/json-ld11/ | +schema:name | +JSON-LD | +
https://www.w3.org/TR/json-ld11/ | +foaf:topic | +Linking Data | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +foaf:interest | +https://www.w3.org/TR/json-ld11/ | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
https://www.w3.org/TR/json-ld11/ | +rdf:type | +foaf:Document | +
https://www.w3.org/TR/json-ld11/ | +schema:name | +JSON-LD | +
https://www.w3.org/TR/json-ld11/ | +foaf:topic | +Linking Data | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +foaf:interest | +https://www.w3.org/TR/json-ld11/ | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/docs/1 | +dc:modified | +2010-05-29T14:17:39+02:00 | +xsd:dateTime | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
_:b0 | +dc:modified | +2010-05-29T14:17:39+02:00 | +xsd:dateTime | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.org/posts#TripToWestVirginia | +rdf:type | +schema:BlogPosting | ++ |
http://example.org/posts#TripToWestVirginia | +dc:modified | +2010-05-29T14:17:39+02:00 | +xsd:dateTime | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/people#john | +foaf:name | +John Smith | ++ |
http://example.com/people#john | +foaf:age | +41 | +xsd:integer | +
http://example.com/people#john | +foaf:homepage | +http://personal.example.org/ | +IRI | +
http://example.com/people#john | +foaf:homepage | +http://work.example.com/jsmith/ | +IRI | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
_:b0 | +foaf:age | +41 | +xsd:integer | +
_:b0 | +foaf:name | +John Smith | ++ |
_:b0 | +foaf:homepage | +http://personal.example.org/ | ++ |
_:b0 | +foaf:homepage | +http://work.example.com/jsmith/ | ++ |
Subject | +Property | +Value | +Language | +
---|---|---|---|
_:b0 | +http://example.org/name | +花澄 | +ja | +
_:b0 | +http://example.org/occupation | +科学者 | +ja | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +joe | +
http://example.org/people#joebob | +foaf:nick | +bob | +
http://example.org/people#joebob | +foaf:nick | +JB | +
Subject | +Property | +Value | +Language | +
---|---|---|---|
http://example.org/articles/8 | +dc:title | +Das Kapital | +de | +
http://example.org/articles/8 | +dc:title | +Capital | +en | +
Subject | +Property | +Value | +Language | +Value Type | +
---|---|---|---|---|
http://example.org/people#michael | +schema:name | +Michael | ++ | + |
http://example.org/people#michael | +schema:name | +Mike | ++ | + |
http://example.org/people#michael | +schema:name | +Miguel | +es | ++ |
http://example.org/people#michael | +schema:name | +https://www.wikidata.org/wiki/Q4927524 | ++ | + |
http://example.org/people#michael | +schema:name | +42 | ++ | xsd:integer | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +_:b0 | +
_:b0 | +rdf:first | +joe | +
_:b0 | +rdf:rest | +_:b1 | +
_:b1 | +rdf:first | +bob | +
_:b1 | +rdf:rest | +_:b2 | +
_:b2 | +rdf:first | +jaybee | +
_:b2 | +rdf:rest | +rdf:nil | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +_:b0 | +
_:b0 | +rdf:first | +joe | +
_:b0 | +rdf:rest | +_:b1 | +
_:b1 | +rdf:first | +bob | +
_:b1 | +rdf:rest | +_:b2 | +
_:b2 | +rdf:first | +jaybee | +
_:b2 | +rdf:rest | +rdf:nil | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
_:b0 | +rdf:type | +geojson:Feature | ++ |
_:b0 | +geojson:bbox | +_:b1 | ++ |
_:b0 | +geojson:geometry | +_:b5 | ++ |
_:b1 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b1 | +rdf:rest | +_:b2 | ++ |
_:b2 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b2 | +rdf:rest | +_:b3 | ++ |
_:b3 | +rdf:first | +1.0E1 | +xsd:double | +
_:b3 | +rdf:rest | +_:b4 | ++ |
_:b4 | +rdf:first | +1.0E1 | +xsd:double | +
_:b4 | +rdf:rest | +rdf:nil | ++ |
_:b5 | +rdf:type | +geojson:Polygon | ++ |
_:b5 | +geojson:coordinates | +_:b6 | ++ |
_:b6 | +rdf:first | +_:b7 | ++ |
_:b6 | +rdf:rest | +rdf:nil | ++ |
_:b7 | +rdf:first | +_:b8 | ++ |
_:b7 | +rdf:rest | +_:b10 | ++ |
_:b8 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b8 | +rdf:rest | +_:b9 | ++ |
_:b9 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b9 | +rdf:rest | +rdf:nil | ++ |
_:b10 | +rdf:first | +_:b11 | ++ |
_:b10 | +rdf:rest | +_:b13 | ++ |
_:b11 | +rdf:first | +1.0E1 | +xsd:double | +
_:b11 | +rdf:rest | +_:b12 | ++ |
_:b12 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b12 | +rdf:rest | +rdf:nil | ++ |
_:b13 | +rdf:first | +_:b14 | ++ |
_:b13 | +rdf:rest | +_:b16 | ++ |
_:b14 | +rdf:first | +1.0E1 | +xsd:double | +
_:b14 | +rdf:rest | +_:b15 | ++ |
_:b15 | +rdf:first | +1.0E1 | +xsd:double | +
_:b15 | +rdf:rest | +rdf:nil | ++ |
_:b16 | +rdf:first | +_:b17 | ++ |
_:b16 | +rdf:rest | +rdf:nil | ++ |
_:b17 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b17 | +rdf:rest | +_:b18 | ++ |
_:b18 | +rdf:first | +-1.0E1 | +xsd:double | +
_:b18 | +rdf:rest | +rdf:nil | ++ |
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +joe | +
http://example.org/people#joebob | +foaf:nick | +bob | +
http://example.org/people#joebob | +foaf:nick | +jaybee | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +joe | +
http://example.org/people#joebob | +foaf:nick | +bob | +
http://example.org/people#joebob | +foaf:nick | +jaybee | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/myresource | +foaf:homepage | +http://example.org | +
http://example.org/myresource | +skos:prefLabel | +This is the main label for my resource | +
http://example.org/myresource | +skos:altLabel | +This is the other label | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/myresource | +foaf:homepage | +http://example.org | +
http://example.org/myresource | +skos:prefLabel | +This is the main label for my resource | +
http://example.org/myresource | +skos:altLabel | +This is the other label | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/myresource | +foaf:homepage | +http://example.org | +
http://example.org/myresource | +skos:prefLabel | +This is the main label for my resource | +
http://example.org/myresource | +skos:altLabel | +This is the other label | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
http://greggkellogg.net/foaf#me | +schema:knows | +_:b0 | +
Subject | +Property | +Value | +
---|---|---|
_:b0 | +schema:name | +Secret Agent 1 | +
_:b0 | +schema:knows | +_:b1 | +
_:b1 | +schema:name | +Secret Agent 2 | +
_:b1 | +schema:knows | +_:b0 | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/no-language | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
http://example.com/posts/1/no-language | +schema:articleBody | +Unindexed description | ++ |
http://example.com/posts/1/no-language | +schema:wordCount | +20 | +xsd:integer | +
Subject | +Property | +Value | +Language | +
---|---|---|---|
http://example.com/queen | +http://example.com/vocab/label | +The Queen | +en | +
http://example.com/queen | +http://example.com/vocab/label | +Die Königin | +de | +
http://example.com/queen | +http://example.com/vocab/label | +Ihre Majestät | +de | +
Subject | +Property | +Value | +Language | +
---|---|---|---|
http://example.com/queen | +http://example.com/vocab/label | +The Queen | +en | +
http://example.com/queen | +http://example.com/vocab/label | +Die Königin | +de | +
http://example.com/queen | +http://example.com/vocab/label | +Ihre Majestät | +de | +
Subject | +Property | +Value | +Language | +
---|---|---|---|
http://example.com/queen | +http://example.com/vocab/label | +The Queen | +en | +
http://example.com/queen | +http://example.com/vocab/label | +Die Königin | +de | +
http://example.com/queen | +http://example.com/vocab/label | +Ihre Majestät | +de | +
http://example.com/queen | +http://example.com/vocab/label | +The Queen | ++ |
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/ | +schema:blogPost | +_:b0 | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
_:b0 | +schema:articleBody | +Description for object without an @id | ++ |
_:b0 | +schema:wordCount | +20 | +xsd:integer | +
Subject | +Property | +Value | +
---|---|---|
https://digitalbazaar.com/ | +rdf:type | +schema:Corporation | +
https://digitalbazaar.com/ | +schema:name | +Digital Bazaar | +
https://spec-ops.io | +rdf:type | +schema:ProfessionalService | +
https://spec-ops.io | +schema:name | +Spec-Ops | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:affiliation | +https://digitalbazaar.com/ | +
_:b0 | +schema:affiliation | +https://spec-ops.io | +
Subject | +Property | +Value | +
---|---|---|
https://digitalbazaar.com/ | +rdf:type | +schema:Corporation | +
https://digitalbazaar.com/ | +schema:name | +Digital Bazaar | +
https://spec-ops.io | +rdf:type | +schema:ProfessionalService | +
https://spec-ops.io | +schema:name | +Spec-Ops | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:affiliation | +https://digitalbazaar.com/ | +
_:b0 | +schema:affiliation | +https://spec-ops.io | +
Subject | +Property | +Value | +
---|---|---|
https://digitalbazaar.com/ | +rdf:type | +schema:Corporation | +
https://digitalbazaar.com/ | +schema:name | +Digital Bazaar | +
https://spec-ops.io | +rdf:type | +schema:ProfessionalService | +
https://spec-ops.io | +schema:name | +Spec-Ops | +
http://greggkellogg.net/ | +schema:name | +Gregg Kellogg | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:affiliation | +https://digitalbazaar.com/ | +
_:b0 | +schema:affiliation | +https://spec-ops.io | +
_:b0 | +schema:affiliation | +http://greggkellogg.net/ | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/#homer | +http://example.com/vocab#name | +Homer | +
http://example.org/#bart | +http://example.com/vocab#name | +Bart | +
http://example.org/#bart | +http://example.com/vocab#parent | +http://example.org/#homer | +
http://example.org/#lisa | +http://example.com/vocab#name | +Lisa | +
http://example.org/#lisa | +http://example.com/vocab#parent | +http://example.org/#homer | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/#homer | +http://example.com/vocab#name | +Homer | +
http://example.org/#bart | +http://example.com/vocab#name | +Bart | +
http://example.org/#bart | +http://example.com/vocab#parent | +http://example.org/#homer | +
http://example.org/#lisa | +http://example.com/vocab#name | +Lisa | +
http://example.org/#lisa | +http://example.com/vocab#parent | +http://example.org/#homer | +
Subject | +Property | +Value | +
---|---|---|
http://example.org/#homer | +http://example.com/vocab#name | +Homer | +
http://example.org/#bart | +http://example.com/vocab#name | +Bart | +
http://example.org/#bart | +http://example.com/vocab#parent | +http://example.org/#homer | +
http://example.org/#lisa | +http://example.com/vocab#name | +Lisa | +
http://example.org/#lisa | +http://example.com/vocab#parent | +http://example.org/#homer | +
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.org/foaf-graph | +prov:generatedAtTime | +2012-04-09 | +xsd:date | +
http://example.org/foaf-graph | +http://manu.sporny.org/about#manu | +rdf:type | +foaf:Person | ++ |
http://example.org/foaf-graph | +http://manu.sporny.org/about#manu | +foaf:name | +Manu Sporny | ++ |
http://example.org/foaf-graph | +http://manu.sporny.org/about#manu | +foaf:knows | +http://greggkellogg.net/foaf#me | ++ |
http://example.org/foaf-graph | +http://greggkellogg.net/foaf#me | +rdf:type | +foaf:Person | ++ |
http://example.org/foaf-graph | +http://greggkellogg.net/foaf#me | +foaf:name | +Gregg Kellogg | ++ |
http://example.org/foaf-graph | +http://greggkellogg.net/foaf#me | +foaf:knows | +http://manu.sporny.org/about#manu | ++ |
Subject | +Property | +Value | +
---|---|---|
http://manu.sporny.org/about#manu | +rdf:type | +schema:Person | +
http://manu.sporny.org/about#manu | +schema:name | +Manu Sporny | +
http://manu.sporny.org/about#manu | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
http://greggkellogg.net/foaf#me | +schema:knows | +http://manu.sporny.org/about#manu | +
Subject | +Property | +Value | +
---|---|---|
http://manu.sporny.org/about#manu | +rdf:type | +schema:Person | +
http://manu.sporny.org/about#manu | +schema:name | +Manu Sporny | +
http://manu.sporny.org/about#manu | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
http://greggkellogg.net/foaf#me | +schema:knows | +http://manu.sporny.org/about#manu | +
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.org/foaf-graph | +prov:generatedAtTime | +2012-04-09 | +xsd:date | +
+ | http://example.org/foaf-graph | +https://w3id.org/credentials#claim | +_:b0 | ++ |
+ | http://example.org/foaf-graph | +https://w3id.org/credentials#claim | +_:b1 | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +rdf:type | +foaf:Person | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +foaf:name | +Manu Sporny | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +foaf:knows | +http://greggkellogg.net/foaf#me | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +rdf:type | +foaf:Person | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +foaf:name | +Gregg Kellogg | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +foaf:knows | +http://manu.sporny.org/about#manu | ++ |
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.com/ | +rdf:type | +schema:Blog | ++ |
+ | http://example.com/ | +schema:name | +World Financial News | ++ |
+ | http://example.com/ | +schema:blogPost | +_:b1 | ++ |
+ | http://example.com/ | +schema:blogPost | +_:b2 | ++ |
_:b1 | +http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
_:b1 | +http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
_:b2 | +http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
_:b2 | +http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.com/ | +rdf:type | +schema:Blog | ++ |
+ | http://example.com/ | +schema:name | +World Financial News | ++ |
+ | http://example.com/ | +schema:blogPost | +_:b0 | ++ |
+ | http://example.com/ | +schema:blogPost | +_:b1 | ++ |
_:b0 | +http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
_:b0 | +http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
_:b1 | +http://example.com/posts/1/no-language | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
_:b1 | +http://example.com/posts/1/no-language | +schema:wordCount | +1204 | +xsd:integer | +
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.org/foaf-graph | +http://example.org/graphMap | +http://greggkellogg.net/foaf#me | ++ |
+ | http://example.org/foaf-graph | +http://example.org/graphMap | +http://manu.sporny.org/about#manu | ++ |
+ | http://example.org/foaf-graph | +prov:generatedAtTime | +2012-04-09 | +xsd:date | +
http://greggkellogg.net/foaf#me | +http://greggkellogg.net/foaf#me | +rdf:type | +foaf:Person | ++ |
http://greggkellogg.net/foaf#me | +http://greggkellogg.net/foaf#me | +foaf:name | +Gregg Kellogg | ++ |
http://greggkellogg.net/foaf#me | +http://greggkellogg.net/foaf#me | +foaf:knows | +http://manu.sporny.org/about#manu | ++ |
http://manu.sporny.org/about#manu | +http://manu.sporny.org/about#manu | +rdf:type | +foaf:Person | ++ |
http://manu.sporny.org/about#manu | +http://manu.sporny.org/about#manu | +foaf:name | +Manu Sporny | ++ |
http://manu.sporny.org/about#manu | +http://manu.sporny.org/about#manu | +foaf:knows | +http://greggkellogg.net/foaf#me | ++ |
Graph | +Subject | +Property | +Value | +Value Type | +
---|---|---|---|---|
+ | http://example.org/foaf-graph | +prov:generatedAtTime | +2012-04-09 | +xsd:date | +
+ | http://example.org/foaf-graph | +http://example.org/graphMap | +_:b0 | ++ |
+ | http://example.org/foaf-graph | +http://example.org/graphMap | +_:b1 | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +rdf:type | +foaf:Person | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +foaf:name | +Manu Sporny | ++ |
_:b0 | +http://manu.sporny.org/about#manu | +foaf:knows | +http://greggkellogg.net/foaf#me | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +rdf:type | +foaf:Person | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +foaf:name | +Gregg Kellogg | ++ |
_:b1 | +http://greggkellogg.net/foaf#me | +foaf:knows | +http://manu.sporny.org/about#manu | ++ |
Subject | +Property | +Value | +
---|---|---|
_:b0 | +foaf:name | +Manu Sporny | +
_:b0 | +foaf:homepage | +http://manu.sporny.org/ | +
Leveraging the popular schema.org vocabulary, the example above could be unambiguously expressed as follows:
-- -+
In the example above, every property is unambiguously identified by an IRI and all values representing IRIs are explicitly marked as such by the @@ -659,17 +742,62 @@
- -+
The referenced context not only specifies how the terms map to IRIs in the Schema.org vocabulary but also @@ -695,27 +823,71 @@
- -+
This section only covers the most basic features of the JSON-LD Context. The Context can also be used to help interpret other more @@ -800,18 +972,56 @@
Term-to-IRI expansion occurs if the key matches a term defined within the active context:
-- -+
JSON keys that do not expand to an IRI, such as status
in the example above, are not Linked Data and thus ignored when processed.
If type coercion rules are specified in the @context
for
a particular term or property IRI, an IRI is generated:
- -+ } + --> + +
+ ++
Subject | Property | Value |
---|---|---|
_:b0 | schema:url | http://manu.sporny.org/ |
+ ++
In the example above, since the value http://manu.sporny.org/
is expressed as a JSON string, the type coercion
@@ -880,20 +1128,57 @@
In JSON-LD, a node is identified using the @id
keyword:
- -+
The example above contains a node object identified by the IRI
http://me.markus-lanthaler.com/
.
In Linked Data, it is common to specify the type of a graph node;
- in many cases, this can be inferred based on the properties used within a
- given node object, or the property for which a node is a value. For
- example, in the schema.org vocabulary, the givenName
- property is associated with a Person. Therefore, one may reason that
- if a node object contains the property firstName, that the
- type is a Person; making this explicit with @type
helps
- to clarify the association.
In Linked Data, it is common to specify the type of a graph node;
+ in many cases, this can be inferred based on the properties used within a
+ given node object, or the property for which a node is a value. For
+ example, in the schema.org vocabulary, the givenName
+ property is associated with a Person. Therefore, one may reason that
+ if a node object contains the property firstName, that the
+ type is a Person; making this explicit with @type
helps
+ to clarify the association.
The type of a particular node can be specified using the @type
- keyword. In Linked Data, types are uniquely
- identified with an IRI.
- -- -
A node can be assigned more than one type by using an array:
+The type of a particular node can be specified using the @type
+ keyword. In Linked Data, types are uniquely
+ identified with an IRI.
The value of an @type
key may also be a term defined in the active context:
- -+
A node can be assigned more than one type by using an array:
-This section only covers the most basic features associated with
- types in JSON-LD. It is worth noting that the @type
- keyword is not only used to specify the type of a
- node but also to express typed values
- (as described in ) and to
- type coerce values (as described in
- ). Specifically, @type
- cannot be used in a context to define a node's
- type. For a detailed description of the differences, please refer to
- .
The value of an @type
key may also be a term defined in the active context:
JSON-LD has a number of features that provide functionality above and beyond + + +
This section only covers the most basic features associated with
+ types in JSON-LD. It is worth noting that the @type
+ keyword is not only used to specify the type of a
+ node but also to express typed values
+ (as described in ) and to
+ type coerce values (as described in
+ ). Specifically, @type
+ cannot be used in a context to define a node's
+ type. For a detailed description of the differences, please refer to
+ .
JSON-LD has a number of features that provide functionality above and beyond the core functionality described above. JSON can be used to express data using such structures, and the features described in this section can be used to interpret a variety of different JSON structures as @@ -1022,21 +1427,64 @@
- -+
In this case, a document residing at http://manu.sporny.org/about
may contain the example above, and reference another document at
@@ -1048,24 +1496,76 @@
- -+ "name": "Manu Sporny", + ****"knows": {**** + "@id": "http://greggkellogg.net/foaf#me", + "@type": "Person", + "name": "Gregg Kellogg" + ****}**** + } + --> + +
+ ++
Subject | Property | Value |
---|---|---|
http://manu.sporny.org/about#manu | rdf:type | schema:Person |
http://manu.sporny.org/about#manu | schema:name | Manu Sporny |
http://greggkellogg.net/foaf#me | rdf:type | schema:Person |
http://greggkellogg.net/foaf#me | schema:name | Gregg Kellogg |
http://manu.sporny.org/about#manu | schema:knows | http://greggkellogg.net/foaf#me |
+ ++
See details these relationships.
@@ -1095,51 +1595,173 @@- -+ ] + --> + +
+ ++
Subject | Property | Value | Value Type |
---|---|---|---|
_:b0 | foaf:name | Manu Sporny | |
_:b0 | foaf:homepage | http://manu.sporny.org/ | |
_:b0 | foaf:depiction | http://twitter.com/account/profile_image/manusporny | |
_:b1 | dc:title | The Empire State Building | |
_:b1 | dc:description | The Empire State Building is a 102-story landmark in New York City. | |
_:b2 | geo:lat | 40.75 | xsd:decimal |
_:b2 | geo:long | 73.98 | xsd:decimal |
_:b1 | schema:geo | _:b2 |
+ ++
Duplicate context terms are overridden using a most-recently-defined-wins mechanism.
-- -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
_:b1 | http://example.com/organization#name | Graz University of Technology |
_:b0 | http://example.com/person#details | _:b1 |
_:b0 | http://example.com/person#name | Markus Lanthaler |
+ ++
In the example above, the name
term is overridden
in the more deeply nested details
structure. Note that this is
@@ -1163,22 +1785,67 @@
- -+
When possible, the context definition should be put at the top of a JSON-LD document. This makes the document easier to read and @@ -1233,9 +1900,16 @@
- -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
http://example.org/places#BrewEats | rdf:type | schema:Restaurant |
http://example.org/places#BrewEats | schema:name | Brew Eats |
+ ++
If @vocab
is used but certain keys in an
dictionary should not be expanded using
@@ -1255,31 +1961,71 @@
databaseId
member would not expand to an
IRI causing the property to be dropped when expanding.
- - ++
+ -- -
In some cases, vocabulary terms are defined directly within the document + "@type": ["http://schema.org/Restaurant"], + "http://schema.org/name": [{"@value": "Brew Eats"}] + }] + --> + +
Subject | Property | Value |
---|---|---|
http://example.org/places#BrewEats | rdf:type | schema:Restaurant |
http://example.org/places#BrewEats | schema:name | Brew Eats |
+ ++ + +
In some cases, vocabulary terms are defined directly within the document
itself, rather than in an external vocabulary. Since
json-ld-1.1
, the vocabulary mapping in the active
context can be set to the empty string ""
, which causes terms which
are expanded relative to the vocabulary, such as the keys of node
objects, to use the base IRI to create absolute
IRIs.
@@ -1297,18 +2043,45 @@+Using the Document Base as the Default Vocabulary
} -->
If this document were located at http://example/document
, it would expand as follows:
- -+ --> + +
Subject | Property | Value |
---|---|---|
http://example.org/places#BrewEats | rdf:type | http://example/document#Restaurant |
http://example.org/places#BrewEats | http://example/document#name | Brew Eats |
+ ++
@base
mapping, to overwrite the base IRI for the document.
- - -+
Setting @base
to null will prevent
relative IRIs from being expanded to
@@ -1379,20 +2189,62 @@
foaf:name
would be expanded to the IRI
http://xmlns.com/foaf/0.1/name
.
- - -+
In the example above, foaf:name
expands to the IRI
http://xmlns.com/foaf/0.1/name
and foaf:Person
expands
@@ -1413,25 +2265,78 @@
It's also possible to use compact IRIs within the context as shown in the following example:
-- -+
In JSON-LD 1.0, terms may be chosen as compact IRI prefixes when compacting only if a simple term definition is used where the value ends with a @@ -1456,21 +2361,67 @@
/
, #
and others, see [[!RFC3986]]).
- - -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
http://example.com/compact-iris-are-considered | http://example.com/property | @prefix does not require a gen-delim |
_:b0 | http://example.com/property | http://example.com/compact-iris-are-considered |
+ ++
In this case, the compact-iris term would not normally be usable as a prefix, both because it is defined with an expanded term definition, and because @@ -1489,21 +2440,61 @@
- -+
In the example above, the @id
and @type
keywords have been given the aliases
@@ -1679,81 +2670,176 @@
- -+
In this case, the social profile is defined using the schema.org vocabulary, but interest is imported from FOAF, and is used to define a node describing one of Manu's interests where those properties now come from the FOAF vocabulary.
Expanding this document, uses a combination of terms defined in the outer context, and those defined specifically for that term in an embedded context.
-- --
Scoping can also be performed using a term used as a value of @type
:
- -- -
Scoping on @type
is useful when common properties are used to
- relate things of different types, where the vocabularies in use within
- different entities calls for different context scoping. For example,
- hasPart
/partOf
may be common terms used in a document, but mean
- different things depending on the context.
When expanding, each value of @type
is considered
+ -->
+
+
+ ++
Subject | Property | Value |
---|---|---|
_:b0 | rdf:type | schema:Person |
https://www.w3.org/TR/json-ld11/ | rdf:type | foaf:Document |
https://www.w3.org/TR/json-ld11/ | schema:name | JSON-LD |
https://www.w3.org/TR/json-ld11/ | foaf:topic | Linking Data |
_:b0 | schema:name | Manu Sporny |
_:b0 | foaf:interest | https://www.w3.org/TR/json-ld11/ |
+ ++ + +
Scoping on @type
is useful when common properties are used to
+ relate things of different types, where the vocabularies in use within
+ different entities calls for different context scoping. For example,
+ hasPart
/partOf
may be common terms used in a document, but mean
+ different things depending on the context.
When expanding, each value of @type
is considered
(ordering them lexographically) where that value is also a term in
the active context having its own embedded context. If so, that
embedded context is applied to the active context. When compacting, if
@@ -1799,78 +2885,134 @@
The first example uses the @type
keyword to associate a
type with a particular term in the @context
:
- -- -
The modified key's value above is automatically type coerced to a
- dateTime value because of the information specified in the
- @context
. A JSON-LD processor will interpret the example above
- as follows:
Subject | -Property | -Value | -Value Type | -
---|---|---|---|
http://example.com/docs/1 | -dc:modified | -2010-05-29T14:17:39+02:00 | -xsd:dateTime | -
The modified key's value above is automatically type coerced to a
+ dateTime value because of the information specified in the
+ @context
. The example tabs show how a JSON-LD processor will interpret the data.
The second example uses the expanded form of setting the type information in the body of a JSON-LD document:
-- -+
Both examples above would generate the value
2010-05-29T14:17:39+02:00
with the type
@@ -1894,7 +3036,7 @@
The first use of @type
associates a node type
(http://schema.org/BlogPosting
) with the node,
which is expressed using the @id
keyword.
@@ -1928,28 +3057,51 @@
@type
keyword is expressing a
node type. The example above expresses the following data:
-Subject | -Property | -Value | -Value Type | -
---|---|---|---|
http://example.org/posts#TripToWestVirginia | -rdf:type | -schema:BlogPosting | -- | -
http://example.org/posts#TripToWestVirginia | -dc:modified | -2010-05-29T14:17:39+02:00 | -xsd:dateTime | -
The example below demonstrates how a JSON-LD author can coerce values to typed values and IRIs.
-- -- -
The example shown above would generate the following data:
- - - -Subject | -Property | -Value | -Value Type | -
---|---|---|---|
http://example.com/people#john | -foaf:name | -John Smith | -- |
http://example.com/people#john | -foaf:age | -41 | -xsd:integer | -
http://example.com/people#john | -foaf:homepage | -http://personal.example.org/ | -IRI | -
http://work.example.com/jsmith/ | -IRI | -
Terms may also be defined using absolute IRIs or compact IRIs. This allows coercion rules to be applied to keys which are not represented as a simple term. For example:
-- ++
+ -+ --> + +
Subject | Property | Value | Value Type |
---|---|---|---|
_:b0 | foaf:age | 41 | xsd:integer |
_:b0 | foaf:name | John Smith | |
_:b0 | foaf:homepage | http://personal.example.org/ | |
_:b0 | foaf:homepage | http://work.example.com/jsmith/ |
+ ++
In this case the @id
definition in the term definition is optional.
If it does exist, the compact IRI or IRI representing
@@ -2116,27 +3349,70 @@
@language
key in the context:
- - -- -
The example above would associate the ja
language
- code with the two strings 花澄 and 科学者.
- Languages codes are defined in [[!BCP47]]. The default language applies to all
- string values that are not type coerced.
To clear the default language for a subtree, @language
can
- be set to null
in a local context as follows:
The example above would associate the ja
language
+ code with the two strings 花澄 and 科学者.
+ Languages codes are defined in [[!BCP47]]. The default language applies to all
+ string values that are not type coerced.
To clear the default language for a subtree, @language
can
+ be set to null
in a local context as follows:
@@ -2286,270 +3562,427 @@Using the Document Base as the Default Vocabulary
arrays, which are ordered by default. For example, consider the following simple document: -- -+Multiple values may also be expressed using the expanded form:
-- -+ + +The example shown above would generates statement, again with + no inherent order.
Although multiple values of a property are typically of the same type, JSON-LD places no restriction on this, and a property may have values of different types:
-- +++ ++
Subject | +Property | +Value | +Language | +Value Type | +
---|---|---|---|---|
http://example.org/people#michael | +schema:name | +Michael | ++ | + |
http://example.org/people#michael | +schema:name | +Mike | ++ | + |
http://example.org/people#michael | +schema:name | +Miguel | +es | ++ |
http://example.org/people#michael | +schema:name | +https://www.wikidata.org/wiki/Q4927524 | ++ | + |
http://example.org/people#michael | +schema:name | +42 | ++ | xsd:integer | +
+ -+ "Mike", + "Miguel"@es, +
When viewed as statements, the values have no inherent order.
-The example shown above would generate the following data, also with - no inherent order:
- -Subject | -Property | -Value | -Language | -Value Type | -
---|---|---|---|---|
http://example.org/people#michael | -dc:name | -Michael | -- | - |
http://example.org/people#michael | -dc:name | -Mike | -- | - |
http://example.org/people#michael | -dc:name | -Miguel | -es | -- |
http://example.org/people#michael | -dc:name | -https://www.wikidata.org/wiki/Q4927524 | -- | - |
http://example.org/people#michael | -dc:name | -42 | -- | xsd:integer | -
As the notion of ordered collections is rather important in data
modeling, it is useful to have specific language support. In JSON-LD,
a list may be represented using the @list
keyword as follows:
- -+
This describes the use of this array as being ordered,
and order is maintained when processing a document. If every use of a given multi-valued
property is a list, this may be abbreviated by setting @container
to @list
in the context:
- -+ "@id": "http://example.org/people#joebob", + "nick": ****[ "joe", "bob", "jaybee" ]****####, + ...#### + } + --> + +
+ ++
Subject | Property | Value |
---|---|---|
http://example.org/people#joebob | foaf:nick | _:b0 |
_:b0 | rdf:first | joe |
_:b0 | rdf:rest | _:b1 |
_:b1 | rdf:first | bob |
_:b1 | rdf:rest | _:b2 |
_:b2 | rdf:first | jaybee |
_:b2 | rdf:rest | rdf:nil |
+ ++
The implementation of lists in RDF depends on linking anonymous nodes
together using the properties rdf:first
and
rdf:rest
, with the end of the list defined as the resource
- rdf:nil
. This can be represented as triples, as the following
- example shows:
Subject | -Property | -Value | -
---|---|---|
http://example.org/people#joebob | -foaf:nick | -_:b0 | -
_:b0 | -rdf:first | -joe | -
_:b0 | -rdf:rest | -_:b1 | -
_:b1 | -rdf:first | -bob | -
_:b1 | -rdf:rest | -_:b2 | -
_:b2 | -rdf:first | -jaybee | -
_:b2 | -rdf:rest | -rdf:nil | -
JSON-LD provides a syntactic shortcut for these lists. In Turtle, the graph would be expressed as follows:
+rdf:nil
. This can be represented as statments, as the "statements"
+ tab illustrates.
-- -+
Both JSON-LD and Turtle provide shortcuts for representing ordered lists.
In JSON-LD 1.1, lists of lists, where the value of a list object, may itself be a list object, are @@ -2584,95 +4017,149 @@
-{ - "@context": { - "@vocab": "https://purl.org/geojson/vocab#", - "type": "@type", - "bbox": {"@container": "@list"}, - "coordinates": {"@container": "@list"} - }, - "type": "Feature", - "bbox": [-10.0, -10.0, 10.0, 10.0], - "geometry": { - "type": "Polygon", - "coordinates": [ - [ - [-10.0, -10.0], - [10.0, -10.0], - [10.0, 10.0], - [-10.0, -10.0] - ] - ] ++ + +
Note that coordinates includes three levels of lists.
Values of terms associated with an @list
container
are always represented in the form of an array,
@@ -2695,43 +4182,162 @@
- -+
This describes the use of this array as being unordered,
and order is maintained when processing a document. By default,
arrays of values are unordered, but this may be made explicit by
setting @container
to @set
in the context:
-
- -+ "@id": "http://example.org/people#joebob", + "nick": ****[ "joe", "bob", "jaybee" ]****####, + ...#### + } + --> + +
+ ++
Subject | +Property | +Value | +
---|---|---|
http://example.org/people#joebob | +foaf:nick | +joe | +
http://example.org/people#joebob | +foaf:nick | +bob | +
http://example.org/people#joebob | +foaf:nick | +jaybee | +
+ ++
Since JSON-LD 1.1, the @set
keyword may be
combined with other container specifications within an expanded term
@@ -2748,27 +4354,95 @@
- -+ --> + +
+ ++
Subject | +Property | +Value | +
---|---|---|
http://example.org/myresource | +foaf:homepage | +http://example.org | +
http://example.org/myresource | +skos:prefLabel | +This is the main label for my resource | +
http://example.org/myresource | +skos:altLabel | +This is the other label | +
+ ++
By defining labels using the keyword @nest
,
a JSON-LD processor will ignore the nesting created by using the
@@ -2778,48 +4452,183 @@
@nest
causes it to be ignored when expanding, making it
equivalent to the following:
- - -+
Similarly, node objects may contain a @nest
property to
reference a term aliased to @nest
which causes such
values to be nested under that aliased term.
- -+ --> + +
+ ++
Subject | +Property | +Value | +
---|---|---|
http://example.org/myresource | +foaf:homepage | +http://example.org | +
http://example.org/myresource | +skos:prefLabel | +This is the main label for my resource | +
http://example.org/myresource | +skos:altLabel | +This is the other label | +
+ ++
Nested properties are a new feature in JSON-LD 1.1, requiring
processing mode set to json-ld-1.1
.
Without embedding, node objects can be linked by referencing the identifier of another node object. For example:
-- ++
+ ++
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
+ ++ + +
The previous example describes two node objects, for Manu and Gregg, with
+ the knows
property defined to treat string values as identifiers.
+ Embedding allows the node object for Gregg to be embedded as a value
+ of the knows
property:
A node object, like the one used above, may be used in
any value position in the body of a JSON-LD document. Note that Using the Document Base as the Default Vocabulary
we would need to introduce a blank node identifier
(here _:b0
).
- -+ --> + +
+ ++
Subject | +Property | +Value | +
---|---|---|
_:b0 | +rdf:type | +schema:Person | +
_:b0 | +schema:name | +Manu Sporny | +
_:b0 | +schema:knows | +http://greggkellogg.net/foaf#me | +
http://greggkellogg.net/foaf#me | +rdf:type | +schema:Person | +
http://greggkellogg.net/foaf#me | +schema:name | +Gregg Kellogg | +
http://greggkellogg.net/foaf#me | +schema:knows | +_:b0 | +
+ ++ +
Blank node identifiers may be automatically introduced by algorithms such as flattening, but they are also useful for authors to describe such relationships directly.
- -+
The example above contains information about two secret agents that cannot be identified with an IRI. While expressing that agent 1 knows agent 2 @@ -2998,185 +5130,378 @@
@index
keyword with a
@container
declaration in the context:
- - ++
+ -- -
In the example above, the post term has
- been marked as an index map. The en and
- de keys will be ignored semantically, but preserved
- syntactically, by the JSON-LD Processor. This allows a developer to
- access the German version of the post using the
- following code snippet: obj.post.de
.
The interpretation of the data above is expressed in - the table below. Note how the index keys do not appear in the Linked Data - below, but would continue to exist if the document were compacted or - expanded (see and - ) using a JSON-LD processor:
- -Subject | Property | Value | +Value Type |
---|---|---|---|
http://example.com/ | -rdf:type | -schema:Blog | -|
http://example.com/ | -schema:name | -World Financial News | -|
http://example.com/ | -schema:blogPost | -http://example.com/posts/1/en | -|
http://example.com/ | -schema:blogPost | -http://example.com/posts/1/de | -|
http://example.com/posts/1/en | -schema:articleBody | -World commodities were up today with heavy trading of crude oil... | -|
http://example.com/posts/1/en | -schema:wordCount | -1539 | -|
http://example.com/posts/1/de | -schema:articleBody | -Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | -|
http://example.com/posts/1/de | -schema:wordCount | -1204 | -|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
The value of @container
can also
- be an array containing both @index
and @set
.
- When compacting, this ensures that a JSON-LD Processor will use
- the array form for all values of indexes.
+ ++ -
- -+
In the example above, the post term has
+ been marked as an index map. The en and
+ de keys will be ignored semantically, but preserved
+ syntactically, by the JSON-LD Processor. This allows a developer to
+ access the German version of the post using the
+ following code snippet: obj.post.de
.
The interpretation of the data is expressed in + the statements table. Note how the index keys do not appear in the statements, + but would continue to exist if the document were compacted or + expanded (see and + ) using a JSON-LD processor.
+ +The value of @container
can also
+ be an array containing both @index
and @set
.
+ When compacting, this ensures that a JSON-LD Processor will use
+ the array form for all values of indexes.
If the processing mode is set to json-ld-1.1
,
the special index @none
is used for indexing
data which does not have an associated index, which is useful to maintain
a normalized representation.
- -+ --> + +
+ ++
Subject | +Property | +Value | +Value Type | +
---|---|---|---|
http://example.com/ | +rdf:type | +schema:Blog | ++ |
http://example.com/ | +schema:name | +World Financial News | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/de | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/en | ++ |
http://example.com/ | +schema:blogPost | +http://example.com/posts/1/no-language | ++ |
http://example.com/posts/1/de | +schema:articleBody | +Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | ++ |
http://example.com/posts/1/de | +schema:wordCount | +1204 | +xsd:integer | +
http://example.com/posts/1/en | +schema:articleBody | +World commodities were up today with heavy trading of crude oil... | ++ |
http://example.com/posts/1/en | +schema:wordCount | +1539 | +xsd:integer | +
http://example.com/posts/1/no-language | +schema:articleBody | +Unindexed description | ++ |
http://example.com/posts/1/no-language | +schema:wordCount | +20 | +xsd:integer | +
+ ++
JSON which includes string values in multiple languages may be represented using a language map to allow for easily @@ -3186,25 +5511,71 @@
@language
keyword with a
@container
declaration in the context:
- - -+ --> + +
+ ++
Subject | Property | Value | Language |
---|---|---|---|
http://example.com/queen | http://example.com/vocab/label | The Queen | en |
http://example.com/queen | http://example.com/vocab/label | Die Königin | de |
http://example.com/queen | http://example.com/vocab/label | Ihre Majestät | de |
+ ++
In the example above, the label term has been marked as an language map. The en and @@ -3218,52 +5589,147 @@
- -+ --> + +
+ ++
Subject | Property | Value | Language |
---|---|---|---|
http://example.com/queen | http://example.com/vocab/label | The Queen | en |
http://example.com/queen | http://example.com/vocab/label | Die Königin | de |
http://example.com/queen | http://example.com/vocab/label | Ihre Majestät | de |
+ ++
If the processing mode is set to json-ld-1.1
,
the special index @none
is used for indexing
data which does not have a language, which is useful to maintain
a normalized representation.
- -+ --> + +
+ ++
Subject | Property | Value | Language |
---|---|---|---|
http://example.com/queen | http://example.com/vocab/label | The Queen | en |
http://example.com/queen | http://example.com/vocab/label | Die Königin | de |
http://example.com/queen | http://example.com/vocab/label | Ihre Majestät | de |
http://example.com/queen | http://example.com/vocab/label | The Queen |
+ ++
@id
keyword with a
@container
declaration in the context:
- - -+ } + --> + +
+ ++
Subject | Property | Value | Value Type |
---|---|---|---|
http://example.com/ | rdf:type | schema:Blog | |
http://example.com/ | schema:name | World Financial News | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/de | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/en | |
http://example.com/posts/1/de | schema:articleBody | Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | |
http://example.com/posts/1/de | schema:wordCount | 1204 | xsd:integer |
http://example.com/posts/1/en | schema:articleBody | World commodities were up today with heavy trading of crude oil... | |
http://example.com/posts/1/en | schema:wordCount | 1539 | xsd:integer |
+ ++
In the example above, the post
term has
been marked as an id map. The http://example.com/posts/1/en
and
@@ -3322,37 +5859,108 @@
- -+ --> + +
+ ++
Subject | Property | Value | Value Type |
---|---|---|---|
http://example.com/ | rdf:type | schema:Blog | |
http://example.com/ | schema:name | World Financial News | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/de | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/en | |
http://example.com/posts/1/de | schema:articleBody | Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | |
http://example.com/posts/1/de | schema:wordCount | 1204 | xsd:integer |
http://example.com/posts/1/en | schema:articleBody | World commodities were up today with heavy trading of crude oil... | |
http://example.com/posts/1/en | schema:wordCount | 1539 | xsd:integer |
+ ++
The special index @none
is used for indexing
node objects which do not have an @id
, which is useful to maintain
@@ -3360,42 +5968,124 @@
@none
, such as the term none
used in the example below.
- - -+ --> + +
+ ++
Subject | Property | Value | Value Type |
---|---|---|---|
http://example.com/ | rdf:type | schema:Blog | |
http://example.com/ | schema:name | World Financial News | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/de | |
http://example.com/ | schema:blogPost | http://example.com/posts/1/en | |
http://example.com/ | schema:blogPost | _:b0 | |
http://example.com/posts/1/de | schema:articleBody | Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | |
http://example.com/posts/1/de | schema:wordCount | 1204 | xsd:integer |
http://example.com/posts/1/en | schema:articleBody | World commodities were up today with heavy trading of crude oil... | |
http://example.com/posts/1/en | schema:wordCount | 1539 | xsd:integer |
_:b0 | schema:articleBody | Description for object without an @id | |
_:b0 | schema:wordCount | 20 | xsd:integer |
+ ++
Id maps are a new feature in JSON-LD 1.1, requiring
processing mode set to json-ld-1.1
.
@type
keyword with a
@container
declaration in the context:
- - -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
https://digitalbazaar.com/ | rdf:type | schema:Corporation |
https://digitalbazaar.com/ | schema:name | Digital Bazaar |
https://spec-ops.io | rdf:type | schema:ProfessionalService |
https://spec-ops.io | schema:name | Spec-Ops |
_:b0 | schema:name | Manu Sporny |
_:b0 | schema:affiliation | https://digitalbazaar.com/ |
_:b0 | schema:affiliation | https://spec-ops.io |
+ ++
In the example above, the affiliation
term has
been marked as an type map. The schema:Corporation
and
@@ -3449,33 +6203,97 @@
- -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
https://digitalbazaar.com/ | rdf:type | schema:Corporation |
https://digitalbazaar.com/ | schema:name | Digital Bazaar |
https://spec-ops.io | rdf:type | schema:ProfessionalService |
https://spec-ops.io | schema:name | Spec-Ops |
_:b0 | schema:name | Manu Sporny |
_:b0 | schema:affiliation | https://digitalbazaar.com/ |
_:b0 | schema:affiliation | https://spec-ops.io |
+ ++
The special index @none
is used for indexing
node objects which do not have an @type
, which is useful to maintain
@@ -3483,38 +6301,114 @@
@none
, such as the term none
used in the example below.
- - -+ --> + +
+ ++
Subject | Property | Value |
---|---|---|
https://digitalbazaar.com/ | rdf:type | schema:Corporation |
https://digitalbazaar.com/ | schema:name | Digital Bazaar |
https://spec-ops.io | rdf:type | schema:ProfessionalService |
https://spec-ops.io | schema:name | Spec-Ops |
http://greggkellogg.net/ | schema:name | Gregg Kellogg |
_:b0 | schema:name | Manu Sporny |
_:b0 | schema:affiliation | https://digitalbazaar.com/ |
_:b0 | schema:affiliation | https://spec-ops.io |
_:b0 | schema:affiliation | http://greggkellogg.net/ |
+ ++
As with id maps, when used with @type
, a container may also
include @set
to ensure that key values are always contained in an array.
- ++
+ -+ "@id": "http://example.org/#lisa", + "http://example.com/vocab#name": [{"@value": "Lisa"}], + "http://example.com/vocab#parent": [{"@id": "http://example.org/#homer"} + ] + }] + --> + +
Subject | Property | Value |
---|---|---|
http://example.org/#homer | http://example.com/vocab#name | Homer |
http://example.org/#bart | http://example.com/vocab#name | Bart |
http://example.org/#bart | http://example.com/vocab#parent | http://example.org/#homer |
http://example.org/#lisa | http://example.com/vocab#name | Lisa |
http://example.org/#lisa | http://example.com/vocab#parent | http://example.org/#homer |
+ ++
Expressing such data is much simpler by using JSON-LD's @reverse
keyword:
- ++
+ ++
+ ++
Subject | Property | Value |
---|---|---|
http://example.org/#homer | http://example.com/vocab#name | Homer |
http://example.org/#bart | http://example.com/vocab#name | Bart |
http://example.org/#bart | http://example.com/vocab#parent | http://example.org/#homer |
http://example.org/#lisa | http://example.com/vocab#name | Lisa |
http://example.org/#lisa | http://example.com/vocab#parent | http://example.org/#homer |
+ ++ + +
The @reverse
keyword can also be used in
+ expanded term definitions
+ to create reverse properties as shown in the following example:
@graph
keyword by pairing it with an
@id
keyword as shown in the following example:
- - ++
+ -+ "@type": ["http://xmlns.com/foaf/0.1/Person"], + "http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}], + "http://xmlns.com/foaf/0.1/knows": [ + {"@id": "http://manu.sporny.org/about#manu"} + ] + }] + }] + --> + +
Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.org/foaf-graph | prov:generatedAtTime | 2012-04-09 | xsd:date | |
http://example.org/foaf-graph | http://manu.sporny.org/about#manu | rdf:type | foaf:Person | |
http://example.org/foaf-graph | http://manu.sporny.org/about#manu | foaf:name | Manu Sporny | |
http://example.org/foaf-graph | http://manu.sporny.org/about#manu | foaf:knows | http://greggkellogg.net/foaf#me | |
http://example.org/foaf-graph | http://greggkellogg.net/foaf#me | rdf:type | foaf:Person | |
http://example.org/foaf-graph | http://greggkellogg.net/foaf#me | foaf:name | Gregg Kellogg | |
http://example.org/foaf-graph | http://greggkellogg.net/foaf#me | foaf:knows | http://manu.sporny.org/about#manu |
+ ++
The example above expresses a named graph that is identified
by the IRI http://example.org/foaf-graph
. That
graph is composed of the statements about Manu and Gregg. Metadata about
the graph itself is expressed via the generatedAt
property,
- which specifies when the graph was generated. An alternative view of the
- information above is represented in table form below:
Graph | -Subject | -Property | -Value | -Value Type | -
---|---|---|---|---|
- | http://example.org/foaf-graph | -prov:generatedAtTime | -2012-04-09 | -xsd:date | -
http://example.org/foaf-graph | -http://manu.sporny.org/about#manu | -xsd:type | -foaf:Person | -- |
http://example.org/foaf-graph | -http://manu.sporny.org/about#manu | -foaf:name | -Manu Sporny | -- |
http://example.org/foaf-graph | -http://manu.sporny.org/about#manu | -foaf:knows | -http://greggkellogg.net/foaf#me | -- |
http://example.org/foaf-graph | -http://greggkellogg.net/foaf#me | -xsd:type | -foaf:Person | -- |
http://example.org/foaf-graph | -http://greggkellogg.net/foaf#me | -foaf:name | -Gregg Kellogg | -- |
http://example.org/foaf-graph | -http://greggkellogg.net/foaf#me | -foaf:knows | -http://manu.sporny.org/about#manu | -- |
When a JSON-LD document's top-level structure is an dictionary that contains no other @@ -3730,54 +6856,183 @@
@graph
keyword collects such nodes in an array
and allows the use of a shared context.
- - ++
+ ++
Subject | Property | Value |
---|---|---|
http://manu.sporny.org/about#manu | rdf:type | schema:Person |
http://manu.sporny.org/about#manu | schema:name | Manu Sporny |
http://manu.sporny.org/about#manu | schema:knows | http://greggkellogg.net/foaf#me |
http://greggkellogg.net/foaf#me | rdf:type | schema:Person |
http://greggkellogg.net/foaf#me | schema:name | Gregg Kellogg |
http://greggkellogg.net/foaf#me | schema:knows | http://manu.sporny.org/about#manu |
+ ++ + +
In this case, embedding doesn't work as each node object
+ references the other. This is equivalent to using multiple
+ node objects in array and defining
+ the @context
within each node object:
An alternative to our example above could use an anonymously named graph - as follows:
+An alternative to our example above could use an anonymously named graph + as follows:
-- ++
+ -+ ****"@graph"****: [{ + "@id": "http://greggkellogg.net/foaf#me", + "@type": ["http://xmlns.com/foaf/0.1/Person"], + "http://xmlns.com/foaf/0.1/name": [{"@value": "Gregg Kellogg"}], + "http://xmlns.com/foaf/0.1/knows": [ + {"@id": "http://manu.sporny.org/about#manu"} + ] + }] + }] + }] + --> + +
Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.org/foaf-graph | prov:generatedAtTime | 2012-04-09 | xsd:date | |
http://example.org/foaf-graph | https://w3id.org/credentials#claim | _:b0 | ||
http://example.org/foaf-graph | https://w3id.org/credentials#claim | _:b1 | ||
_:b0 | http://manu.sporny.org/about#manu | rdf:type | foaf:Person | |
_:b0 | http://manu.sporny.org/about#manu | foaf:name | Manu Sporny | |
_:b0 | http://manu.sporny.org/about#manu | foaf:knows | http://greggkellogg.net/foaf#me | |
_:b1 | http://greggkellogg.net/foaf#me | rdf:type | foaf:Person | |
_:b1 | http://greggkellogg.net/foaf#me | foaf:name | Gregg Kellogg | |
_:b1 | http://greggkellogg.net/foaf#me | foaf:knows | http://manu.sporny.org/about#manu |
+ ++
The example above expresses a named graph that is identified
by the blank node identifier _:b0
. That
graph is composed of the statements about Manu and Gregg. Metadata about
the graph itself is expressed via the generatedAt
property,
- which specifies when the graph was generated. An alternative view of the
- information above is represented in table form below:
Graph | -Subject | -Property | -Value | -Value Type | -
---|---|---|---|---|
- | http://example.org/foaf-graph | -prov:generatedAtTime | -2012-04-09 | -xsd:date | -
- | http://example.org/foaf-graph | -cred:claim | -_:b0 | -- |
_:b0 | -http://manu.sporny.org/about#manu | -xsd:type | -foaf:Person | -- |
_:b0 | -http://manu.sporny.org/about#manu | -foaf:name | -Manu Sporny | -- |
_:b0 | -http://manu.sporny.org/about#manu | -foaf:knows | -http://greggkellogg.net/foaf#me | -- |
_:b0 | -http://greggkellogg.net/foaf#me | -xsd:type | -foaf:Person | -- |
_:b0 | -http://greggkellogg.net/foaf#me | -foaf:name | -Gregg Kellogg | -- |
_:b0 | -http://greggkellogg.net/foaf#me | -foaf:knows | -http://manu.sporny.org/about#manu | -- |
The blank node identifier _:b0
is automatically created to allow the default graph to reference the
@@ -3916,42 +7184,6 @@
Expanding this graph results in the following:
- -- --
Strictly speaking, the value of such a term is not a named graph, rather it is the graph name associated with the named graph, which exists separately within @@ -3974,141 +7206,120 @@
The following example describes a default graph referencing multiple named graphs using an index map.
-- -- -
This expands to the following:
- -- ++
+ -+ "@index": "de" + }] + }] + --> + +
Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.com/ | rdf:type | schema:Blog | ||
http://example.com/ | schema:name | World Financial News | ||
http://example.com/ | schema:blogPost | _:b1 | ||
http://example.com/ | schema:blogPost | _:b2 | ||
_:b1 | http://example.com/posts/1/de | schema:articleBody | Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | |
_:b1 | http://example.com/posts/1/de | schema:wordCount | 1204 | xsd:integer |
_:b2 | http://example.com/posts/1/en | schema:articleBody | World commodities were up today with heavy trading of crude oil... | |
_:b2 | http://example.com/posts/1/en | schema:wordCount | 1539 | xsd:integer |
+ ++
As with index maps, when used with @graph
, a container may also
include @set
to ensure that key values are always contained in an array.
@index
key.
- - -- -
This expands to the following:
- -- ++
+ -+ }] + --> + +
Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.com/ | rdf:type | schema:Blog | ||
http://example.com/ | schema:name | World Financial News | ||
http://example.com/ | schema:blogPost | _:b0 | ||
http://example.com/ | schema:blogPost | _:b1 | ||
_:b0 | http://example.com/posts/1/en | schema:articleBody | World commodities were up today with heavy trading of crude oil... | |
_:b0 | http://example.com/posts/1/en | schema:wordCount | 1539 | xsd:integer |
_:b1 | http://example.com/posts/1/no-language | schema:articleBody | Die Werte an Warenbörsen stiegen im Sog eines starken Handels von Rohöl... | |
_:b1 | http://example.com/posts/1/no-language | schema:wordCount | 1204 | xsd:integer |
+ ++
The following example describes a default graph referencing multiple named graphs using an id map.
-- -- -
This expands to the following:
- -- ++
+ -- -
When expressed as Quads, this becomes the following:
+ --> + +Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.org/foaf-graph | http://example.org/graphMap | http://greggkellogg.net/foaf#me | ||
http://example.org/foaf-graph | http://example.org/graphMap | http://manu.sporny.org/about#manu | ||
http://example.org/foaf-graph | prov:generatedAtTime | 2012-04-09 | xsd:date | |
http://greggkellogg.net/foaf#me | http://greggkellogg.net/foaf#me | rdf:type | foaf:Person | |
http://greggkellogg.net/foaf#me | http://greggkellogg.net/foaf#me | foaf:name | Gregg Kellogg | |
http://greggkellogg.net/foaf#me | http://greggkellogg.net/foaf#me | foaf:knows | http://manu.sporny.org/about#manu | |
http://manu.sporny.org/about#manu | http://manu.sporny.org/about#manu | rdf:type | foaf:Person | |
http://manu.sporny.org/about#manu | http://manu.sporny.org/about#manu | foaf:name | Manu Sporny | |
http://manu.sporny.org/about#manu | http://manu.sporny.org/about#manu | foaf:knows | http://greggkellogg.net/foaf#me |
+ ++
As with id maps, when used with @graph
, a container may also
include @set
to ensure that key values are always contained in an array.
@none
judiciously, and consider giving graphs
their own distinct identifier.
- - ++
+ ++
Graph | Subject | Property | Value | Value Type |
---|---|---|---|---|
http://example.org/foaf-graph | prov:generatedAtTime | 2012-04-09 | xsd:date | |
http://example.org/foaf-graph | http://example.org/graphMap | _:b0 | ||
http://example.org/foaf-graph | http://example.org/graphMap | _:b1 | ||
_:b0 | http://manu.sporny.org/about#manu | rdf:type | foaf:Person | |
_:b0 | http://manu.sporny.org/about#manu | foaf:name | Manu Sporny | |
_:b0 | http://manu.sporny.org/about#manu | foaf:knows | http://greggkellogg.net/foaf#me | |
_:b1 | http://greggkellogg.net/foaf#me | rdf:type | foaf:Person | |
_:b1 | http://greggkellogg.net/foaf#me | foaf:name | Gregg Kellogg | |
_:b1 | http://greggkellogg.net/foaf#me | foaf:knows | http://manu.sporny.org/about#manu |
+ -+ + _:b1 { +
Graph Containers are a new feature in JSON-LD 1.1, requiring
processing mode set to json-ld-1.1
.
Running the JSON-LD Expansion algorithm against the JSON-LD input document provided above would result in the following output:
-- -+
JSON-LD's media type defines a
profile
parameter which can be used to signal or request
@@ -4524,7 +7875,8 @@
Additionally, assume the following developer-supplied JSON-LD context:
+ title="Sample context" + data-context-for="Sample expanded JSON-LD document">@@ -4656,7 +8012,10 @@
Mechinism to allow freezing terms so that additional contexts don't override them.
Should consider html>head>base@href
and xml:base
, as appropriate.
Update terminology in the spec from IRI to URL.
-For every example, there should be an equivalent of the example in the expanded form, in a table with the triples, in turtle (as close to the JSON-LD structure as possible) and, possibly, as graphs. Not all of them would appear on the screen at the same time but, rather, the reader could choose what to see with some tabs.
+For every example, there should be an equivalent of the example in the expanded form, in a table with the triples, in [[Turtle]] (as close to the JSON-LD structure as possible) and, possibly, as graphs. Not all of them would appear on the screen at the same time but, rather, the reader could choose what to see with some tabs.
Proposal is to start from scratch, ie, deprecating @graph
and replacing the functionality with something cleaner.