-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathindex.html
3172 lines (2952 loc) · 137 KB
/
index.html
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
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
<!DOCTYPE html>
<html lang="en">
<head>
<title>JSON-LD 1.1 Framing</title>
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
<script src="https://www.w3.org/Tools/respec/respec-w3c" class="remove" defer></script>
<script src="common/common.js" class="remove" defer></script>
<script src="common/jsonld.js" class="remove"></script>
<script class="remove">
var respecConfig = {
// extend the bibliography entries
localBiblio: jsonld.localBiblio,
// specification status (e.g. WD, LCWD, NOTE, etc.). If in doubt use ED.
specStatus: "ED",
// if you wish the publication date to be other than today, set this
//publishDate: "2012-08-30",
copyrightStart: "2010",
// the specification's short name, as in http://www.w3.org/TR/short-name/
shortName: "json-ld11-framing",
subtitle: "An Extension to the Application Programming Interface for the JSON-LD Syntax",
// if there is a previously published draft, uncomment this and set its YYYY-MM-DD date
// and its maturity status
prevVersion: "https://www.w3.org/TR/2020/PR-json-ld11-framing-20200507/",
previousPublishDate: "2020-05-07",
previousMaturity: "PR",
errata: "https://w3c.github.io/json-ld-framing/errata/",
// if there a publicly available Editor's Draft, this is the link
edDraftURI: "https://w3c.github.io/json-ld-framing/",
testSuiteURI: "https://w3c.github.io/json-ld-framing/tests/",
implementationReportURI:"https://w3c.github.io/json-ld-api/reports/",
crEnd: "2020-04-03",
prEnd: "2020-06-18",
github: {
repoURL: "https://github.com/w3c/json-ld-framing/",
branch: "main"
},
// if this is a LCWD, uncomment and set the end of its review period
// lcEnd: "2009-08-05",
// if you want to have extra CSS, append them to this list
// it is recommended that the respec.css stylesheet be kept
// extraCSS: [],
includePermalinks: true,
doJsonLd: true,
highlightVars: true,
pluralize: true,
// Cross-reference definitions
xref: ["json-ld11", "json-ld11-api"],
// editors, add as many as you like
// only "name" is required
editors: [
{ name: "Dave Longley",
url: "https://digitalbazaar.com/",
w3cid: "48025",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0 and v1.1"},
{ name: "Gregg Kellogg",
url: "https://greggkellogg.net/",
w3cid: "44770",
note: "v1.0 and v1.1"},
{ name: "Pierre-Antoine Champin",
url: "http://champin.net/",
company: "LIRIS - Université de Lyon",
companyURL: "https://liris.cnrs.fr/",
w3cid: "42931",
note: "v1.1" }
],
formerEditors: [
{ name: "Manu Sporny",
url: "http://manu.sporny.org/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Markus Lanthaler",
url: "https://www.markus-lanthaler.com/",
company: "Google",
companyURL: "https://www.google.com/",
note: "v1.0" }
],
// authors, add as many as you like.
// This is optional, uncomment if you have authors as well as editors.
// only "name" is required. Same format as editors.
authors: [
{ name: "Dave Longley",
url: "https://digitalbazaar.com/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Manu Sporny",
url: "http://manu.sporny.org/",
company: "Digital Bazaar",
companyURL: "https://digitalbazaar.com/",
note: "v1.0" },
{ name: "Gregg Kellogg",
url: "https://greggkellogg.net/",
w3cid: "44770",
note: "v1.0 and v1.1" },
{ name: "Markus Lanthaler",
url: "https://www.markus-lanthaler.com/",
company: "Google",
companyURL: "https://www.google.com/",
note: "v1.0" },
{ name: "Niklas Lindström",
url: "http://neverspace.net/",
note: "v1.0" }
],
group: "wg/json-ld",
wgPublicList: "public-json-ld-wg",
maxTocLevel: 4,
alternateFormats: [ {uri: "json-ld11-framing.epub", label: "EPUB"} ]
};
</script>
<script>
document.addEventListener("DOMContentLoaded", () => {
// Add example button selection logic
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");
}
}
// Toggle show/hide changes
for (const elem of document.querySelectorAll(".show-changes")) {
elem.onclick = () => {
if (elem.classList.contains("selected")) {
// Remove highlight class from elements having "changed" class
elem.classList.remove("selected");
for (const changed of document.querySelectorAll(".changed")) {
changed.classList.remove("highlight");
}
} else {
// Add highlight class to elements having "changed" class
elem.classList.add("selected");
for (const changed of document.querySelectorAll(".changed")) {
changed.classList.add("highlight");
}
}
}
}
});
</script>
<style>
.hl-bold {font-weight: bold; color: #0a3;}
.comment {color: #999;}
table, thead, tr, td { padding: 5px; border-width: 1px; border-spacing: 0px; border-style: solid; border-collapse: collapse; }
table.example {width: 100%;}
.error a {
color: #ff4500;
border-bottom: 1px dotted #ff4500;
text-decoration: none;
}
.example > pre.context:before {
content: "Context";
float: right;
font: x-large Arial, sans-serif;
color: gray;
border: solid thin black;
padding: 0.2em;
}
.example > pre.frame:before {
content: "Frame";
float: right;
font: x-large Arial, sans-serif;
color: gray;
border: solid thin black;
padding: 0.2em;
}
.example > pre.input:before {
content: "Input";
float: right;
font: x-large Arial, sans-serif;
color: gray;
border: solid thin black;
padding: 0.2em;
}
.example > pre.result:before {
content: "Result";
float: right;
font: x-large Arial, sans-serif;
color: gray;
border: solid thin black;
padding: 0.2em;
}
.example > pre.turtle:before {
content: "Turtle";
float: right;
font: x-large Arial, sans-serif;
color: gray;
border: solid thin black;
padding: 0.2em;
}
.algorithm ol {
counter-reset: numsection;
list-style-type: none;
}
.algorithm li {
margin: 0.5em 0;
}
.algorithm li:before {
font-weight: bold;
counter-increment: numsection;
content: counters(numsection, ".") ") ";
}
.highlight.changed, .show-changes {
background-color: lime;
}
.show-changes.selected:before {
content: "de-highlight";
}
.show-changes:before {
content: "highlight";
}
aside.example {
overflow-y: hidden;
}
/* example tab selection */
.ds-selector-tabs {
padding-bottom: 2em;
}
.ds-selector-tabs .selectors {
padding: 0;
border-bottom: 1px solid #ccc;
height: 28px;
}
.ds-selector-tabs .selectors button {
display: inline-block;
min-width: 54px;
text-align: center;
font-size: 11px;
font-weight: bold;
height: 27px;
padding: 0 8px;
line-height: 27px;
transition: all,0.218s;
border-top-right-radius: 2px;
border-top-left-radius: 2px;
color: #666;
border: 1px solid transparent;
}
.ds-selector-tabs .selectors button:first-child {
margin-left: 2px;
}
.ds-selector-tabs .selectors button.selected {
color: #202020 !important;
border: 1px solid #ccc;
border-bottom: 1px solid #fff !important;
}
.ds-selector-tabs .selectors button:hover {
background-color: transparent;
color: #202020;
cursor: pointer;
}
.ds-selector-tabs pre:not(.preserve), .ds-selector-tabs table:not(.preserve) {
display: none;
}
.ds-selector-tabs pre.selected, .ds-selector-tabs table.selected {
display: block;
}
a.playground {
display: inline-block;
width: 150px;
border: 1px solid transparent;
border-top-right-radius: 2px;
border-top-left-radius: 2px;
background-color: rgb(192, 192, 192);
text-decoration: none;
font-size: 13px;
margin-bottom: 10px;
}
a[href].playground {
padding: 4px 0 3px 8px;
border-bottom: none;
text-decoration: none;
color: #666;
}
</style>
</head>
<body>
<section id="abstract">
<p>JSON-LD Framing allows developers to query by example and
force a specific tree layout to a JSON-LD document.</p>
<p>This specification describes a superset of the features defined in
[[[JSON-LD10-FRAMING]]] [[JSON-LD10-FRAMING]]
and, except where noted,
the algorithms described in this specification are fully compatible
with documents created using the previous community standard.</p>
</section>
<section id='sotd'>
<p>This document has been developed by the
<a href="https://www.w3.org/2018/json-ld-wg/">JSON-LD Working Group</a> and was derived from the <a href="https://www.w3.org/community/json-ld/">JSON-LD Community Group's</a> <a href="https://www.w3.org/2018/jsonld-cg-reports/json-ld-framing/">Final Report</a>.</p>
<p>There is a
<a href="https://json-ld.org/playground/">live JSON-LD playground</a> that is capable
of demonstrating the features described in this document.</p>
<section>
<h2>Set of Documents</h2>
<p>This document is one of three JSON-LD 1.1 Recommendations produced by the
<a href="https://www.w3.org/2018/json-ld-wg/">JSON-LD Working Group</a>:</p>
<ul>
<li>[[[JSON-LD11]]]</li>
<li>[[[JSON-LD11-API]]]</li>
<li><a href="">JSON-LD 1.1 Framing</a></li>
</ul>
</section>
</section>
<section id='introduction' class="informative">
<h1>Introduction</h1>
<p>JSON-LD is a lightweight syntax to serialize Linked Data [[LINKED-DATA]] in JSON [[RFC8259]].
Its design allows existing JSON to be interpreted as Linked Data with minimal changes.
As with other representations of Linked Data which describe directed graphs,
a single directed graph can have many different serializations, each expressing
exactly the same information. Developers typically work with trees, represented as
<a>JSON objects</a>. While mapping a graph to
a tree can be done, the layout of the end result must be specified in advance.
A <a>Frame</a> can be used by a developer on a JSON-LD document to
specify a deterministic layout for a graph.</p>
<p>Using delimiters around a chunk of data is known as "framing".
JSON-LD uses JSON delimiters such as <code>{</code> and <code>}</code> to
separate statements about a particular subject. JSON-LD also allows subjects
to reference other subjects through the use of their identifiers, expressed
as strings.</p>
<p>However, given that JSON-LD represents one or more <a>graphs</a> of information,
there is more than one way to frame the statements about several related
subjects into a whole document. In fact, a graph of information can be
thought of as a long list of independent statements (aka <a>triples</a>) that are not bundled together in any way.</p>
<p>The
<a href="#the-application-programming-interface" class="sectionRef">JSON-LD Framing API</a>
enables a developer to specify exactly how they would like data to be framed,
such that statements about a particular subject are bundled together,
delimited via <code>{</code> and <code>}</code>, and such that the subjects
they relate to "nest" into a particular tree structure that matches what
their application expects.</p>
<section class="informative">
<h2>How to Read this Document</h2>
<p>This document is a detailed specification for a serialization of Linked
Data in JSON. The document is primarily intended for the following audiences:</p>
<ul>
<li>Authors who want to query JSON-LD documents to create representations
more appropriate for a given use case.</li>
<li>Software developers that want to implement <a>processors</a> and APIs for JSON-LD.</li>
</ul>
<p>A companion document, the JSON-LD 1.1 specification
[[JSON-LD11]], specifies the grammar of JSON-LD documents.</p>
<p>To understand the basics in this specification you must first be familiar with
<a data-cite="RFC8259" data-no-xref="">JSON</a>, which is detailed in [[RFC8259]].
You must also understand the JSON-LD 1.1 Syntax specification [[JSON-LD11]],
which is the base syntax used by all of the algorithms in this document,
and the JSON-LD 1.1 API [[JSON-LD11-API]].
To understand the API and how it is intended to operate in a programming environment,
it is useful to have working knowledge of
the JavaScript programming language [[ECMASCRIPT]]
and WebIDL [[WEBIDL]].
To understand how JSON-LD maps to RDF, it is helpful to be
familiar with the basic RDF concepts [[RDF11-CONCEPTS]].</p>
<p>This document can highlight changes since the [[[JSON-LD10]]] version.
Select to <button class="show-changes"></button> changes.</p>
</section>
<section class="informative">
<h2>Contributing</h2>
<p>There are a number of ways that one may participate in the development of
this specification:</p>
<ul>
<li>Technical discussion typically occurs on the public mailing list:
<a href="https://lists.w3.org/Archives/Public/public-json-ld-wg/">public-json-ld-wg@w3.org</a></li>
<li>The working group uses <a href="https://irc.w3.org/?channels=json-ld">#json-ld</a>
IRC channel is available for real-time discussion on <a href="https://irc.w3.org">irc.w3.org</a>.</li>
<li>The <a href="https://webchat.freenode.net/?channels=json-ld">#json-ld</a>
IRC channel is also available for real-time discussion on irc.freenode.net.</li>
</ul>
</section>
<section class="informative">
<h2>Typographical conventions</h2>
<div data-include="common/typographical-conventions.html"></div>
</section>
<section class="normative">
<h2>Terminology</h2>
<p>This document uses the following terms as defined in external specifications
and defines terms specific to JSON-LD.</p>
<div data-include="common/terms.html"></div>
<section>
<h4>Algorithm Terms</h4>
<p>The Following terms are used within specific algorithms.</p>
<div data-include="common/algorithm-terms.html"></div>
</section>
</section>
<section id="framing-keywords">
<h2>Syntax Tokens and Keywords</h2>
<p>This specification adds a number of <a>keywords</a> (<dfn>framing keywords</dfn>) to
the ones defined in the JSON-LD 1.1 Syntax specification [[JSON-LD11]]:</p>
<dl data-sort>
<dt><code>@default</code></dt>
<dd>Used in <a href="#framing">Framing</a> to set the default value for
an output property when the framed <a>node object</a> does not include such a property.</dd>
<dt><code>@embed</code></dt>
<dd>Used in <a href="#framing">Framing</a> to override the
value of <a>object embed flag</a> within a specific frame. Valid values for
<code>@embed</code> as the following:
<dl data-sort>
<dt><code>@always</code></dt><dd>
Always embed <a>node objects</a> as property values, unless this would
cause a circular reference.
</dd>
<dt class="changed"><code>@once</code></dt><dd class="changed">
Just a single value within a given <a>node object</a> should be embedded,
other values of other properties use a <a>node reference</a>. This is the
default value if neither <code>@embed</code> nor <a>object embed flag</a>
is specified.
<div class="note">The specific <a>node object</a> chosen to embed depends on
ordering. If the {{JsonLdOptions/ordered}} flag is <code>true</code>,
this will be the first <a>node object</a> encountered,
otherwise, it may be any node object.</div>
</dd>
<dt><code>@never</code></dt><dd>
Always use a <a>node reference</a> when serializing matching values.
</dd>
</dl>
<p>Any other value for <code>@embed</code> is invalid and indicates that an
<a data-link-for="JsonLdFramingErrorCode">invalid @embed value</a>
error has been detected and processing is aborted.</p>
</dd>
<dt><code>@explicit</code></dt>
<dd>Used in <a href="#framing">Framing</a> to override the
value of <a>explicit inclusion flag</a> within a specific frame.</dd>
<dt><code>@null</code></dt>
<dd>Used in <a href="#framing">Framing</a> when a value of <code>null</code>
should be returned, which would otherwise be removed when
<a data-cite="JSON-LD11-API#compaction">Compacting</a>.</dd>
<dt><code>@omitDefault</code></dt>
<dd>Used in <a href="#framing">Framing</a> to override the
value of <a>omit default flag</a> within a specific frame.
</dd>
<dt class="changed"><code>@requireAll</code></dt>
<dd class="changed">Used in <a href="#framing">Framing</a> to override the
value of <a>require all flag</a> within a specific frame.</dd>
</dl>
<p>All JSON-LD tokens and keywords are case-sensitive.</p>
</section>
</section>
<section class="informative">
<h2>Features</h2>
<p class="changed">JSON-LD 1.1 introduces new features that are
compatible with [[[JSON-LD10]]] [[JSON-LD10]],
but if processed by a JSON-LD 1.0 processor may produce different results.
Processors default to `json-ld-1.1`, unless the
{{JsonLdOptions/processingMode}} API option
is explicitly set to `json-ld-1.0`.
Publishers are encouraged to use the <code>@version</code> <a>map entry</a> within a <a>context</a>
set to `1.1` to ensure that JSON-LD 1.0 processors will not misinterpret JSON-LD 1.1 features.</p>
<section class="informative">
<h3>Framing</h3>
<p><dfn class="lint-ignore">Framing</dfn> is used to shape the data in a <a>JSON-LD document</a>,
using an example <a>frame</a> document which is used to both match the
<a data-cite="JSON-LD11-API#dfn-flattened">flattened</a>
data and show an example of how the resulting data should be shaped.
Matching is performed by using <a>properties</a> present in in the <a>frame</a>
to find objects in the data that share common values. Matching can be done
either using all properties present in the frame, or any property in the frame.
By chaining together objects using matched property values, objects can be embedded
within one another.</p>
<p>A <a>frame</a> also includes a <a>context</a>, which is used for compacting the resulting
framed output.</p>
<p>For example, assume the following JSON-LD frame:</p>
<pre id="sample-library-frame"
class="example frame" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Flattened library objects"
title="Sample library frame">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@type": "Library",
"contains": {
"@type": "Book",
"contains": {
"@type": "Chapter"
}
}
}
-->
</pre>
<p>This <a>frame</a> document describes an embedding structure that would place
objects with type <em>Library</em> at the top, with objects of
type <em>Book</em> that were linked to the library object using
the <em>contains</em> property embedded as property values. It also
places objects of type <em>Chapter</em> within the referencing <em>Book</em> object
as embedded values of the <em>Book</em> object.</p>
<p>When using a flattened set of objects that match the frame components:</p>
<pre id="flattened-library-objects"
class="example input" data-transform="updateExample"
title="Flattened library objects">
<!--
{
"@context": {
"@vocab": "http://example.org/",
"contains": {"@type": "@id"}
},
"@graph": [{
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
"contains": "http://example.org/library/the-republic"
}, {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
"title": "The Republic",
"contains": "http://example.org/library/the-republic#introduction"
}, {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}]
}
-->
</pre>
<p>The Frame Algorithm can create a new document which follows the structure
of the frame:</p>
<aside id="framed-library-objects"
class="example ds-selector-tabs"
title="Framed library objects">
<div class="selectors">
<a class="playground"
data-result-for="#flattened-library-objects"
data-frame="#sample-library-frame"
target="_blank"
href="">PG</a>
</div>
<pre class="selected framed result" data-transform="updateExample"
data-frame="Sample library frame"
data-result-for="Flattened library objects">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
"title": "The Republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}
}
}
-->
</pre>
</aside>
<p>If <a>processing mode</a> is not <code>json-ld-1.0</code>, or the <a>omit graph flag</a> is <code>true</code>,
the top-level <code>@graph</code> <a>entry</a> may be omitted.</p>
<pre class="example result" data-transform="updateExample"
data-frame="Sample library frame"
data-result-for="Flattened library objects"
title="Framed library objects">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
"title": "The Republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}
}
}
-->
</pre>
<p>The <a href="#framing-algorithm">Framing Algorithm</a> does this by
first expanding both the input frame and document. It then creates
a <a>map of flattened subjects</a>. The outer-most <a>node object</a> within the frame
is used to match objects in the map, in this case looking for <a>node objects</a>
which have an <code>@type</code> of <code>Library</code>, and a
<code>contains</code> property with another
frame used to match values of that property. The input document contains
exactly one such <a>node object</a>. The value of contains also has
a <a>node object</a>, which is then treated as a frame to match the set of <a>subjects</a>
which are <code>contains</code> values of the <code>Library</code> object, and so forth.</p>
<section class="informative"><h4>Matching on Properties</h4>
<p>In addition to matching on types, a frame can match on
one or more properties.</p>
<p>For example, the following frame selects object based on property
values, rather than `@type`.</p>
<pre id="library-frame-with-property-selection"
class="example frame nohighlight" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Flattened library objects"
title="Library frame with property matching">
<!--
{
"@context": {"@vocab": "http://example.org/"},
****"location": "Athens"****,
"contains": {
****"title": "The Republic"****,
"contains": {
****"title": "The Introduction"****
}
}
}
-->
</pre>
<p>This will generate the same framed results as when selecting on `@type`,
as the property values are unique to each node <a>object</a>.</p>
<aside class="example ds-selector-tabs"
title="Framed library objects with property matching">
<div class="selectors">
<a class="playground"
data-result-for="#flattened-library-objects"
data-frame="#library-frame-with-property-selection"
target="_blank"
href="">PG</a>
</div>
<pre class="selected framed result" data-transform="updateExample"
data-frame="Library frame with property matching"
data-result-for="Flattened library objects">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
"title": "The Republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}
}
}
-->
</pre>
</aside>
<p>See <a href="#require-all-flag" class="sectionRef"></a>
to see how matching can be restricted to match <a>node objects</a> containing
all, versus any such listed property.</p>
</section>
<section class="informative"><h4>Wildcard Matching</h4>
<p>The empty <a>map</a> (`{}`) is used as a <a>wildcard</a>, which will
match a property if it exists in a target <a>node object</a>, independent of any specific value.</p>
<p>For example, the following frame selects object based on property
wildcarding, rather than `@type`.</p>
<pre id="library-frame-with-wildcards"
class="example frame nohighlight" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Flattened library objects"
title="Library frame with wildcard matching">
<!--
{
"@context": {"@vocab": "http://example.org/"},
****"location": {}****,
"contains": {
****"creator": {}****,
"contains": {
****"description": {}****
}
}
}
-->
</pre>
<p>This will generate the same framed results as when selecting on `@type`,
as the matched properties are distinct to each <a>node object</a>.</p>
<aside class="example ds-selector-tabs"
title="Framed library objects with wildcard matching">
<div class="selectors">
<a class="playground"
data-result-for="#flattened-library-objects"
data-frame="#library-frame-with-wildcards"
target="_blank"
href="">PG</a>
</div>
<pre class="selected framed result" data-transform="updateExample"
data-frame="Library frame with wildcard matching"
data-result-for="Flattened library objects">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
"title": "The Republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}
}
}
-->
</pre>
</aside>
</section>
<section class="informative"><h4>Match on the Absence of a Property</h4>
<p>The empty <a>array</a> (`[]`) is used for <a>match none</a>, which will
match a node object only if a property does not exist in a target <a>node object</a>.</p>
<p>For example, the following frame selects object based on the absence of properties,
rather than `@type`.</p>
<pre id="library-frame-with-absent-property"
class="example frame nohighlight" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Flattened library objects"
title="Library frame with absent matching">
<!--
{
"@context": {"@vocab": "http://example.org/"},
****"creator": []****,
****"title": []****,
"contains": {
****"location": []****,
****"description": []****,
"contains": {
****"location": []****
}
}
}
-->
</pre>
<p>This will generate the same framed results as when selecting on `@type`,
the property that is excluded uniquely identifies each <a>node object</a>.
Note that additional properties with the value `null` are added
for those properties explicitly excluded.</p>
<aside class="example ds-selector-tabs"
title="Framed library objects with wildcard matching">
<div class="selectors">
<a class="playground"
data-result-for="#flattened-library-objects"
data-frame="#library-frame-with-absent-property"
target="_blank"
href="">PG</a>
</div>
<pre class="selected framed result" data-transform="updateExample"
data-frame="Library frame with absent matching"
data-result-for="Flattened library objects">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": "Athens",
****"creator": null****, ####← This property is added####
****"title": null****, ####← This property is added####
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": "Plato",
****"description": null****, ####← This property is added####
****"location": null****, ####← This property is added####
"title": "The Republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
****"location": null****, ####← This property is added####
"title": "The Introduction"
}
}
}
-->
</pre>
</aside>
</section>
<section class="informative"><h4>Matching on Values</h4>
<p>Frames can be matched based on the presence of specific property values.
These values can themselves use <a>wildcards</a>, to match on a specific
or set of values, <a>language tags</a>, types, or <a data-lt="base direction">base direction</a>.</p>
<p>For an example, we'll use an multilingual version of the library example
with more complex value representations.</p>
<pre id="multilingual-library-objects"
class="example input" data-transform="updateExample"
title="Multilingual library objects">
<!--
{
"@context": {
"@vocab": "http://example.org/",
"contains": {"@type": "@id"}
},
"@graph": [{
"@id": "http://example.org/library",
"@type": "Library",
"location": [
{"@value": "Athens", "@language": "en"},
{"@value": "Αθήνα", "@language": "grc"},
{"@value": "Athína", "@language": "el-Latn"}
],
"contains": "http://example.org/library/the-republic"
}, {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": [
{"@value": "Plato", "@language": "en"},
{"@value": "Πλάτων", "@language": "grc"},
{"@value": "Plátōn", "@language": "el-Latn"}
],
"title": [
{"@value": "The Republic", "@language": "en"},
{"@value": "Πολιτεία", "@language": "grc"},
{"@value": "Res Publica", "@language": "el-Latn"}
],
"contains": "http://example.org/library/the-republic#introduction"
}, {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}]
}
-->
</pre>
<p>By matching on an attribute of a value, we can match frames
having that attribute, and limit results to property values
that match. In this case, we'll frame the Library and Book objects
on values only in latinized Greek (`el-Latn`):</p>
<pre id="library-frame-with-language-matching"
class="example frame nohighlight" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Multilingual library objects"
title="Library frame with language matching">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"location": {"@value": {}, "@language": "el-Latn"},
"contains": {
"creator": {"@value": {}, "@language": "el-Latn"},
"title": {"@value": {}, "@language": "el-Latn"},
"contains": {
"title": "The Introduction"
}
}
}
-->
</pre>
<p>This generates the following framed results:</p>
<aside class="example ds-selector-tabs"
title="Framed library objects with wildcard matching">
<div class="selectors">
<a class="playground"
data-result-for="#multilingual-library-objects"
data-frame="#library-frame-with-language-matching"
target="_blank"
href="">PG</a>
</div>
<!-- ignore as this won't match the input -->
<pre class="selected framed result" data-transform="updateExample"
data-frame="Library frame with language matching"
data-result-for="Multilingual library objects"
data-ignore>
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"@type": "Library",
"location": {"@value": "Athína", "@language": "el-Latn"},
"contains": {
"@id": "http://example.org/library/the-republic",
"@type": "Book",
"creator": {"@value": "Plátōn", "@language": "el-Latn"},
"title": {"@value": "Res Publica", "@language": "el-Latn"},
"contains": {
"@id": "http://example.org/library/the-republic#introduction",
"@type": "Chapter",
"description": "An introductory chapter on The Republic.",
"title": "The Introduction"
}
}
}
-->
</pre>
</aside>
</section>
<section class="informative"><h4>Matching on `@id`</h4>
<p>Frames can be matched if they match a specific
identifier (`@id`). This can be illustrated with the original
<a href="#flattened-library-objects">Flattened library objects</a>
input using a frame which matches on specific `@id` values:</p>
<pre id="library-frame-with-id-matching"
class="example frame nohighlight" data-transform="updateExample"
data-content-type="application/ld+json;profile=http://www.w3.org/ns/json-ld#frame"
data-frame-for="Flattened library objects"
title="Library frame with @id matching">
<!--
{
"@context": {"@vocab": "http://example.org/"},
"@id": "http://example.org/library",
"contains": {
"@id": "http://example.org/library/the-republic",
"contains": {
"@id": "http://example.org/library/the-republic#introduction"
}
}
}
-->
</pre>
<p>This generates the following framed results:</p>
<aside class="example ds-selector-tabs"
title="Framed library objects with @id matching">