json-ld 0.21.4

JSON-LD implementation
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
-# This template is used for generating a rollup EARL report. It expects to be
-# called with a single _tests_ local with the following structure
- require 'cgi'
- require 'digest'
- editors = [{ name: "Gregg Kellogg", url: "http://greggkellogg.net/"}]
- foaf = {name: "Gregg Kellogg", url: "http://greggkellogg.net/foaf#me" }

!!! 5
%html
  - subjects = tests['testSubjects']
  %head
    %meta{"http-equiv" => "Content-Type", :content => "text/html;charset=utf-8"}
    %link{rel: "alternate", href: "earl.jsonld"}
    %link{rel: "stylesheet", href: "https://www.w3.org/StyleSheets/TR/base"}
    - tests['assertions'].each do |file|
      %link{rel: "related", href: file}
    %title
      JSON-LD 1.1 Processor Conformance
    :css
      span[property='dc:description rdfs:comment'] { display: none; }
      td.PASS { color: green; }
      td.FAIL { color: red; }
      table.report {
        border-width: 1px;
        border-spacing: 2px;
        border-style: outset;
        border-color: gray;
        border-collapse: separate;
        background-color: white;
      }
      table.report th {
        border-width: 1px;
        padding: 1px;
        border-style: inset;
        border-color: gray;
        background-color: white;
        -moz-border-radius: ;
      }
      table.report td {
        border-width: 1px;
        padding: 1px;
        border-style: inset;
        border-color: gray;
        background-color: white;
        -moz-border-radius: ;
      }
      tr.summary {font-weight: bold;}
      td.passed-all {color: green;}
      td.passed-most {color: darkorange;}
      td.passed-some {color: red;}
      em.rfc2119 {
        text-transform: lowercase;
        font-variant:   small-caps;
        font-style:     normal;
        color:          #900;
      }
      a.testlink {
        color: inherit;
        text-decoration: none;
      }
      a.testlink:hover {
        text-decoration: underline;
      }
      pre > code {
        color: #C83500;
      }
      .non-normative, .non-normative a:visited, .non-normative a:link {
        color: gray;
      }
      #test-manifests .report td:last-child::before {
        position: absolute;
        left: 1em;
        content: "X";
        color: red;
        font-weight: bold;
      }
      #test-manifests .report tr.summary td:last-child::before,
      #test-manifests .report .PASS ~ td.PASS:last-child::before,
      #test-manifests .report .PASS ~ .PASS ~ td:last-child::before {
        display: none;
      }

  %body{prefix: "bibo: http://purl.org/ontology/bibo/ earl: http://www.w3.org/ns/earl# doap: http://usefulinc.com/ns/doap# mf: http://www.w3.org/2001/sw/DataAccess/tests/test-manifest#", vocab: "http://www.w3.org/ns/earl#"}
    - subject_refs = {}
    - passed_tests = []
    - subjects.each_with_index do |subject, index|
      - frag_id = "subj_#{subject['name']}-#{subject['language']}".gsub(/[\W_]+/, '_')
      - subject_refs[subject['@id']] = frag_id
    %div.head{role: :contentinfo}
      %p
        %a{href: "http://www.w3.org/"}
          %img{width: 72, height: 48, src: "https://www.w3.org/Icons/w3c_home", alt: "W3C"}
      %h1.title.p-name#title{property: "dc:title"}
        JSON-LD 1.1 Processor Conformance
      %h2.subtitle
        EARL results from the JSON-LD 1.1 Test Suite
      %h2#w3c-document-28-october-2015
        %time.dt-published{property: "dc:issued", datetime: Time.now.strftime('%Y-%m-%d')}
          = Time.now.strftime("%d %B %Y")
      %dl
        %dt="Editor:"
        - editors.each do |ed|
          %dd{property: "bibo:editor", inlist: true}<>
            %span{typeof: "foaf:Person"}<>
              %meta{property: "foaf:name", content: ed[:name]}<>
              %a{property: "foaf:homepage", href: ed[:url]}<>
                = ed[:name]
      %p
        This document is also available in these non-normative formats:
        %a{re: "alternate", href: "earl.jsonld"}="JSON-LD"
        = "."
      %p.copyright
        %a{href: "http://www.w3.org/Consortium/Legal/ipr-notice#Copyright"}
          Copyright
        © 2010-2019
        %a{href: "http://www.w3.org/"}
          %sup="®"
        (
        %a{href: "http://www.csail.mit.edu/"}<>
          %abbr{title: "Massachusetts Institute of Technology"}<>="MIT"
        = ", "
        %a{href: "http://www.ercim.eu/"}<>
          %abbr{title: "European Research Consortium for Informatics and Mathematics"}<>="ERCIM"
        = ", "
        %a{href: "http://www.keio.ac.jp/"}<>="Keio"
        = ", "
        %a{href: "http://ev.buaa.edu.cn/"}<>="Beihang"
        ).
        %abbr{title: "World Wide Web Consortium"}="W3C"
        %a{href: "http://www.w3.org/Consortium/Legal/ipr-notice#Legal_Disclaimer"}="liability"
        = ","
        %a{href: "http://www.w3.org/Consortium/Legal/ipr-notice#W3C_Trademarks"}="trademark"
        and
        %a{rel: "license", href: "http://www.w3.org/Consortium/Legal/copyright-documents"}="document use"
        rules apply.
      %hr
    %section#abstract
      %h2="Abstract"
      %p
        This document report test subject conformance for and related specifications for
        %span{property: "doap:name"}<="JSON-LD 1.1 Test Suite"
        according to the requirements of the Evaluation and Report Language (EARL) 1.0 Schema
        [
        %a{href: "https://www.w3.org/TR/EARL10-Schema/"}<>="EARL10-SCHEMA"
        ].
      %p
        This report is also available in alternate formats:
        %a{href: "earl.jsonld"}
          JSON-LD
    %section#sodt
      %h2#h-sotd{resource: "#h-sotd"}
        %span{property: "xhv:role", resource: "xhv:heading"}
          Status of This Document
      %p
        This document is merely a
        = " "
        %abbr{title: "World Wide Web Consortium"}<>="W3C"
        ="-internal  document."
        It has no official standing of any kind and does not represent consensus of the
        %abbr{title: "World Wide Web Consortium"}="W3C"
        Membership.
      %p
        This report describes the state of implementation conformance at the time of publication.
    %section#toc
      %h2.introductory#h-toc{resource: "#h-toc"}
        %span{property: "xhv:role", resource: "xhv:heading"}
          Table of Contents
      %ul.toc#respecContents{role: "directory"}
        %li.tocline
          %a.tocxref{href: "#introduction"}
            %span.secno="1."
            Introduction
        %li.tocline
          %a.tocxref{href: "#instructions-for-submitting-implementation-reports"}
            %span.secno="2."
            Instructions for submitting implementation reports
        %li.tocline
          %a.tocxref{href: "#test-manifests"}
            %span.secno="3."
            Test Manifests
          %ul.toc
            - tests['entries'].sort_by {|m| m['title'].to_s.downcase}.each_with_index do |manifest, ndx|
              %li.tocline
                %span.secno="3.#{ndx+1}"
                %a.tocxref{href: "##{manifest['title'].gsub(' ', '-')}"}
                  ~ manifest['title']
        %li.tocline
          %a.tocxref{href: "#test-subjects"}
            %span.secno="A."
            Test Subjects
          %ul.toc
            - subjects.each_with_index do |subject, ndx|
              %li.tocline
                %span.secno="A.#{ndx+1}"
                %a.tocxref{href: "#" + subject_refs[subject['@id']]}
                  = subject['name']
                  - if subject['language']
                    = " (#{subject['language']})"
        %li.tocline
          %a.tocxref{href: "#individual-test-results"}
            %span.secno="B."
            Individual Test Results
        %li.tocline
          %a.tocxref{href: "#report-generation-software"}
            %span.secno="C."
            Report Generation Software
    %section#introduction
      :markdown
        ## Introduction

        This implementation report covers the implementations of the JSON-LD
        specifications which have submitted test results. It is intended to be
        maintained by the [JSON for Linking Data Community Group](https://www.w3.org/community/json-ld/),
        or a JSON-LD Working Group if one is active.
        The implementation report serves two purposes:

        1. To demonstrate that there are multiple, independent implementations of
          the specifications. This is a prerequisite for progression of any
          standard to Recommendation.

        2. To catalog the known, conforming implementations and which features
          each supports.

        There are other [JSON-LD implementations](http://json-ld.org/#developers) which are not listed in this
        report, either due to not submitting tests or by not being intended as
        direct implementations of the specification, but instead layering on
        top of such libraries. For a broader list of implementations, please
        see the [JSON-LD Website](https://json-ld.org/).
    %section#instructions-for-submitting-implementation-reports
      :markdown
        ## Instructions for submitting implementation reports

          Reports should be submitted in Turtle format to
          [Public JSON-LD WG](mailto:public-json-ld-wg@w3.org) or via a Pull
          Request to the [w3c/json-ld-api](https://github.com/w3c/json-ld-api/pulls).

          Tests should be run using the test manifests defined in the
          [Test Manifests](#test-manifests) Section.

          The assumed base URI for the tests is `<http://example/base/>` if needed.

          Include an `earl:Assertion` for each test, referencing the test
          resource from the associated manifest and the test subject being
          reported upon. See the example below:

              [ a earl:Assertion;
                earl:assertedBy <--your-developer-identifier-->;
                earl:subject <--your-software-identifier-->;
                earl:test <--uri-of-test-from-manifest>;
                earl:result [
                  a earl:TestResult;
                  earl:outcome earl:passed;
                  dc:date "2016-12-26T10:18:04-08:00"^^xsd:dateTime];
                earl:mode earl:automatic ] .

          The Test Subject should be defined as a `doap:Project`, including the name,
          homepage and developer(s) of the software (see [DOAP](https://github.com/edumbill/doap/wiki)). Optionally, including the
          project description and programming language. An example test subject description is the following:

              <> foaf:primaryTopic <--your-software-identifier--> ;
                dc:issued "2016-12-26T10:18:04-08:00"^^xsd:dateTime ;
                foaf:maker <--your-developer-identifier--> .

              <--your-software-identifier--> a doap:Project, earl:TestSubject, earl:Software ;
                doap:name          "My Cool JSON-LD Parser" ;
                doap:release [
                  doap:name     "--short name wih version number--";
                  doap:revision "--Software version number--" ;
                  doap:created  "2020-02-19"^^xsd:date;
                ] ;
                doap:developer     <--your-developer-identifier--> ;
                doap:homepage      <--your-software-homepace--> ;
                doap:description   "--your-project-description--"@en ;
                doap:programming-language "--your-implementation-language--" .

          The software developer, either an organization or one or more individuals SHOULD be
          referenced from `doap:developer` using [FOAF](http://xmlns.com/foaf/spec). For example:

              <--your-developer-identifier--> a foaf:Person, earl:Assertor;
                foaf:name "--My Name--";
                foaf:homepage <--my homepage--> .
    %section#test-manifests
      %h2
        %span.secno="3."
        Test Manifests
      - tests['entries'].sort_by {|m| m['title'].to_s.downcase}.each_with_index do |manifest, ndx2|
        - test_cases = manifest['entries']
        %section{id: manifest['title'].gsub(' ', '-')}
          %h2
            %span.secno="3.#{ndx2+1}"
            %span<
              = manifest['title'] ||  'Test Manifest'
          - Array(manifest['rdfs:comment']).each do |desc|
            - desc = desc['@value'] if desc.is_a?(Hash)
            :markdown
              #{desc}
          %table.report
            - skip_subject = {}
            - passed_tests[ndx2] = []
            %tr
              %th
                Test
              - subjects.each_with_index do |subject, index|
                -# If subject is untested for every test in this manifest, skip it
                - skip_subject[subject['@id']] = manifest['entries'].all? {|t| t['assertions'][index]['result']['outcome'] == 'earl:untested'}
                - unless skip_subject[subject['@id']]
                  %th
                    %a{href: '#' + subject_refs[subject['@id']]}
                      = subject['name']
                      - if subject['language']
                        %br
                        = "(#{subject['language']})"
            - test_cases.each do |test|
              - test['title'] ||= test['rdfs:label']
              - test['title'] = Array(test['title']).first
              - option = test.fetch('https://w3c.github.io/json-ld-api/tests/vocab#option', {})
              - normative = option.fetch('https://w3c.github.io/json-ld-api/tests/vocab#normative', {"@value" => "true"})['@value'] == 'true'
              %tr{class: normative ? 'normative' : 'non-normative'}
                %td
                  %a{href: test['@id']}<
                    = "Test #{test['@id'].split("#").last}: #{CGI.escapeHTML test['title'].to_s}"
                  - other = []
                  - if option['https://w3c.github.io/json-ld-api/tests/vocab#specVersion'] == 'json-ld-1.1'
                    - other << "new in JSON-LD 1.1"
                  - if option['https://w3c.github.io/json-ld-api/tests/vocab#processorFeature']
                    - other << "feature: #{option['https://w3c.github.io/json-ld-api/tests/vocab#processorFeature']}"
                  - if !normative
                    - other << "non-normative"
                  - unless other.empty?
                    = "(#{other.join(', ')})"
                -# Order assertions by subject name
                - subjects.each_with_index do |subject, ndx|
                  - next if skip_subject[subject['@id']]
                  - assertion = test['assertions'].detect {|a| a['subject'] == subject['@id']}
                  - pass_fail = assertion['result']['outcome'].split(':').last.upcase.sub(/(PASS|FAIL)ED$/, '\1')
                  - passed_tests[ndx2][ndx] = (passed_tests[ndx2][ndx] || 0) + (pass_fail == 'PASS' ? 1 : 0)
                  %td{class: pass_fail}
                    = pass_fail
            %tr.summary
              %td
                = "Percentage passed out of #{manifest['entries'].length} Tests"
              - passed_tests[ndx2].compact.each do |r|
                - pct = (r * 100.0) / manifest['entries'].length
                %td{class: (pct == 100.0 ? 'passed-all' : (pct >= 95.0 ? 'passed-most' : 'passed-some'))}
                  = "#{'%.1f' % pct}%"
    %section.appendix#test-subjects
      %h2
        %span.secno="A."
        Test Subjects
      %p
        This report was tested using the following test subjects:
      %dl
        - subjects.each_with_index do |subject, index|
          %dt{id: subject_refs[subject['@id']]}
            %span.secno="A.#{index+1}"
            %a{href: subject['@id']}
              %span{about: subject['@id'], property: "doap:name"}<= subject['name']
          %dd
            %dl
              - if subject['doapDesc']
                - subject['doapDesc'] = subject['doapDesc']['@value'] if subject['doapDesc'].is_a?(Hash)
                %dt= "Description"
                %dd{property: "doap:description", lang: 'en'}<
                  ~ CGI.escapeHTML subject['doapDesc']
              - if subject['release']
                - subject['release'] = subject['release'].first if subject['release'].is_a?(Array)
                - subject['release']['revision'] = subject['release']['revision']['@value'] if subject['release']['revision'].is_a?(Hash)
                %dt= "Release"
                %dd{property: "doap:release"}<
                  %span{property: "doap:revision"}<
                    ~ CGI.escapeHTML subject['release']['revision'].to_s
              - if subject['language']
                - subject['language'] = subject['language']['@value'] if subject['language'].is_a?(Hash)
                %dt= "Programming Language"
                %dd{property: "doap:programming-language"}<
                  ~ CGI.escapeHTML subject['language'].to_s
              - if subject['homepage']
                %dt= "Home Page"
                %dd
                  %a{property: "doap:homepage", href: subject['homepage']}
                    ~ CGI.escapeHTML subject['homepage'].to_s
              - if subject['developer']
                %dt= "Developer"
                - subject['developer'].each do |dev|
                  %dd{rel: "doap:developer"}
                    %div
                      - if dev.has_key?('@id')
                        %a{href: dev['@id']}
                          %span{property: "foaf:name"}<
                            ~ CGI.escapeHTML dev['foaf:name'].to_s
                      - else
                        %span{property: "foaf:name"}<
                      - if dev['foaf:homepage']
                        %a{property: "foaf:homepage", href: dev['foaf:homepage']}
                          ~ CGI.escapeHTML dev['foaf:homepage'].is_a?(Hash) ? dev['foaf:homepage']['@id'] : dev['foaf:homepage']
              %dt
                Test Suite Compliance
              %dd
                %table.report
                  %tbody
                    - tests['entries'].sort_by {|m| m['title'].to_s.downcase}.each_with_index do |manifest, ndx|
                      - passed = passed_tests[ndx][index].to_i
                      - next if passed == 0
                      - total = manifest['entries'].length
                      - pct = (passed * 100.0) / total
                      %tr
                        %td
                          ~ manifest['title']
                        %td{class: (pct == 100.0 ? 'passed-all' : (pct >= 85.0 ? 'passed-most' : 'passed-some'))}
                          = "#{passed}/#{total} (#{'%.1f' % pct}%)"
    - unless tests['assertions'].empty?
      %section.appendix#individual-test-results{rel: "xhv:related earl:assertions"}
        %h2
          %span.secno="B."
          Individual Test Results
        %p
          Individual test results used to construct this report are available here:
        %ul
          - tests['assertions'].each do |file|
            %li
              %a.source{href: file}<= file
    %section.appendix#report-generation-software{property: "earl:generatedBy", resource: tests['generatedBy']['@id'], typeof: tests['generatedBy']['@type'].join(' ')}
      %h2
        %span.secno="C."
        Report Generation Software
      - doap = tests['generatedBy']
      - rel = doap['release']
      %p
        This report generated by
        %span{property: "doap:name"}<
          %a{href: tests['generatedBy']['@id']}<
            = doap['name']
        %meta{property: "doap:shortdesc", content: doap['shortdesc']}
        %meta{property: "doap:description", content: doap['doapDesc']}
        version
        %span{property: "doap:release", resource: rel['@id'], typeof: 'doap:Version'}
          %span{property: "doap:revision"}<=rel['revision']
          %meta{property: "doap:name", content: rel['name']}
          %meta{property: "doap:created", content: rel['created'], datatype: "xsd:date"}
        is a
        %span{property: "doap:programming-language"}<="Ruby"
        application freely available under the generous terms of the
        = " "
        %a{property: "doap:license", href: doap['license']}<>="Unlicense"
        = "."
        More information is available at
        %a{property: "doap:homepage", href: doap['homepage']}<=doap['homepage']
        = "."
      %p{property: "doap:developer", resource: "http://greggkellogg.net/foaf#me", typeof: "foaf:Person"}
        This software is provided by
        %a{property: "foaf:homepage", href: "http://greggkellogg.net/"}<
          %span{about: "http://greggkellogg.net/foaf#me", property: "foaf:name"}<
            Gregg Kellogg
        in hopes that it might make the lives of conformance testers easier.