Skip to content

Commit 3ad9438

Browse files
committed
Merge @datatype into @type. A Note is added in Typed Literals section that indicates that the concepts are actually different. This resolves issue #31.
1 parent 0b425c0 commit 3ad9438

File tree

2 files changed

+42
-39
lines changed

2 files changed

+42
-39
lines changed

spec/latest/json-ld-api/index.html

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -490,7 +490,7 @@ <h3>JsonLdProcessor</h3>
490490
<dl class="exception" title="InvalidContext">
491491
<dt>INVALID_SYNTAX</dt>
492492
<dd>A general syntax error was detected in the <code>@context</code>.
493-
For example, if a <code>@datatype</code> key maps to anything other than
493+
For example, if a <code>@type</code> key maps to anything other than
494494
a string or an array of strings, this exception would be raised.</dd>
495495
<dt>MULTIPLE_DATATYPES</dt>
496496
<dd>There is more than one target datatype specified for a single
@@ -518,7 +518,7 @@ <h3>JsonLdProcessor</h3>
518518
<dl class="exception" title="InvalidContext">
519519
<dt>INVALID_SYNTAX</dt>
520520
<dd>A general syntax error was detected in the <code>@context</code>.
521-
For example, if a <code>@datatype</code> key maps to anything other than
521+
For example, if a <code>@type</code> key maps to anything other than
522522
a string or an array of strings, this exception would be raised.</dd>
523523
<dt>MULTIPLE_DATATYPES</dt>
524524
<dd>There is more than one target datatype specified for a single
@@ -584,7 +584,7 @@ <h3>JsonLdProcessor</h3>
584584
<dl class="exception" title="InvalidContext">
585585
<dt>INVALID_SYNTAX</dt>
586586
<dd>A general syntax error was detected in the <code>@context</code>.
587-
For example, if a <code>@datatype</code> key maps to anything other than
587+
For example, if a <code>@type</code> key maps to anything other than
588588
a string or an array of strings, this exception would be raised.</dd>
589589
<dt>MULTIPLE_DATATYPES</dt>
590590
<dd>There is more than one target datatype specified for a single
@@ -615,7 +615,7 @@ <h3>JsonLdProcessor</h3>
615615
<dl class="exception" title="InvalidContext">
616616
<dt>INVALID_SYNTAX</dt>
617617
<dd>A general syntax error was detected in the <code>@context</code>.
618-
For example, if a <code>@datatype</code> key maps to anything other than
618+
For example, if a <code>@type</code> key maps to anything other than
619619
a string or an array of strings, this exception would be raised.</dd>
620620
<dt>MULTIPLE_DATATYPES</dt>
621621
<dd>There is more than one target datatype specified for a single
@@ -677,11 +677,10 @@ <h2>Syntax Tokens and Keywords</h2>
677677

678678
<dl>
679679
<dt><code>@context</code></dt><dd>Used to set the <tref>local context</tref>.</dd>
680-
<dt><code>@datatype</code></dt><dd>Used to specify the datatype for a literal.</dd>
681680
<dt><code>@id</code></dt><dd>Sets the active subject.</dd>
682681
<dt><code>@language</code></dt><dd>Used to specify the language for a literal.</dd>
683682
<dt><code>@literal</code></dt><dd>Used to specify a literal value.</dd>
684-
<dt><code>@type</code></dt><dd>Used to set the type of the active subject.</dd>
683+
<dt><code>@type</code></dt><dd>Used to set the type of the active subject or the datatype of a literal.</dd>
685684
<dt><code>:</code></dt><dd>The separator for JSON keys and values that use the <tref>prefix</tref> mechanism.</dd>
686685
</dl>
687686
</section>
@@ -815,7 +814,7 @@ <h2 id="context">Context</h2>
815814
<li>For each key in <em>value</em> having the lexical form of <code>NCName</code> or an empty string,
816815
with a value that is a <tref>JSON object</tref>
817816
<ol class="algorithm">
818-
<li>If the value has a <code>@datatype</code> key, the value MUST have the form of <tref>term</tref>,
817+
<li>If the value has a <code>@type</code> key, the value MUST have the form of <tref>term</tref>,
819818
<tref>prefix</tref>:suffix, absolute IRI or the keyword <code>@id</code>. Add a <tref>coercion
820819
mapping</tref> for the term to the <tref>local context</tref> performing <a href="#iri-expansion">IRI
821820
Expansion</a> on the associated value using the <tref>active context</tref> as necessary.</li>
@@ -831,7 +830,7 @@ <h2 id="context">Context</h2>
831830
<tref>active context</tref>'s <tref>list mapping</tref>.</li>
832831
</ol>
833832

834-
<p class="note">Rules for looking up <code>@datatype</code> coercion is performed
833+
<p class="note">Rules for looking up <code>@type</code> coercion is performed
835834
after merging local term definitions into the <tref>active context</tref>. This allows datatype
836835
IRIs to be specified using <tref>term</tref> or <tref>prefix</tref> defined within the same context.</p>
837836
</section>
@@ -901,7 +900,7 @@ <h2>Value Expansion</h2>
901900
<li>If the coercion target is a typed literal, expand the value
902901
by adding two new key-value pairs. The first key-value pair
903902
will be <code>@literal</code> and the unexpanded value. The second
904-
key-value pair will be <code>@datatype</code> and the associated
903+
key-value pair will be <code>@type</code> and the associated
905904
coercion datatype expanded according to the
906905
<a href="#iri-expansion">IRI Expansion</a> rules.</li>
907906
</ol>
@@ -956,7 +955,7 @@ <h2>Expansion</h2>
956955
"name": "http://xmlns.com/foaf/0.1/name",
957956
"homepage": {
958957
"@id": "http://xmlns.com/foaf/0.1/homepage",
959-
"@datatype", "@id"
958+
"@type", "@id"
960959
}
961960
},
962961
"name": "Manu Sporny",
@@ -1044,7 +1043,7 @@ <h2>Compaction</h2>
10441043
"name": "http://xmlns.com/foaf/0.1/name",
10451044
"homepage": {
10461045
"@id": "http://xmlns.com/foaf/0.1/homepage",
1047-
"@datatype": "@id"
1046+
"@type": "@id"
10481047
}
10491048
}
10501049
-->
@@ -1061,7 +1060,7 @@ <h2>Compaction</h2>
10611060
"name": "http://xmlns.com/foaf/0.1/name",
10621061
"homepage": {
10631062
"@id": "http://xmlns.com/foaf/0.1/homepage",
1064-
"@datatype": "@id"
1063+
"@type": "@id"
10651064
}
10661065
},
10671066
"name": "Manu Sporny",
@@ -1126,7 +1125,7 @@ <h2>Framing</h2>
11261125
"Chapter": "http://example.org/vocab#Chapter",
11271126
"contains": {
11281127
"@id": "http://example.org/vocab#contains",
1129-
"@datatype": "@id"
1128+
"@type": "@id"
11301129
},
11311130
"creator": "http://purl.org/dc/terms/creator",
11321131
"description": "http://purl.org/dc/terms/description",
@@ -1428,7 +1427,7 @@ <h2>Normalization</h2>
14281427
"name": "http://xmlns.com/foaf/0.1/name",
14291428
"homepage": {
14301429
"@id": "http://xmlns.com/foaf/0.1/homepage",
1431-
"@datatype": "@id"
1430+
"@type": "@id"
14321431
},
14331432
"xsd": "http://www.w3.org/2001/XMLSchema#"
14341433
},
@@ -1898,7 +1897,7 @@ <h4>Object Comparison Algorithm</h4>
18981897
<code>@literal</code> is first.
18991898
</li>
19001899
<li>The lexicographically lesser string associated with
1901-
<code>@datatype</code> is first.
1900+
<code>@type</code> is first.
19021901
</li>
19031902
<li>The lexicographically lesser string associated with
19041903
<code>@language</code> is first.
@@ -2360,12 +2359,12 @@ <h4>Label Serialization Algorithm</h4>
23602359
where <strong>IRI</strong> is the value associated with the
23612360
<code>@id</code> key.</li>
23622361
<li>If the object contains a <code>@literal</code> key and a
2363-
<code>@datatype</code> key, build the <tref>object string</tref>
2362+
<code>@type</code> key, build the <tref>object string</tref>
23642363
using the pattern
23652364
<code>"</code><strong>LITERAL</strong><code>"^^&lt;</code><strong>DATATYPE</strong><code>&gt;</code>
23662365
where <strong>LITERAL</strong> is the value associated with the
23672366
<code>@literal</code> key and <strong>DATATYPE</strong> is the
2368-
value associated with the <code>@datatype</code> key.</li>
2367+
value associated with the <code>@type</code> key.</li>
23692368
<li>If the object contains a <code>@literal</code> key and a
23702369
<code>@language</code> key, build the <tref>object string</tref>
23712370
using the pattern
@@ -2468,7 +2467,7 @@ <h3>Data Round Tripping</h3>
24682467
var myObj = { "@context" : {
24692468
"number" : {
24702469
"@id": "http://example.com/vocab#number",
2471-
"@datatype": "xsd:nonNegativeInteger"
2470+
"@type": "xsd:nonNegativeInteger"
24722471
}
24732472
},
24742473
"number" : 42 };
@@ -2588,8 +2587,8 @@ <h3>RDF Conversion Algorithm</h3>
25882587
to a literal value as follows:
25892588
<ol class="algorithm">
25902589
<li>
2591-
as a <tref>typed literal</tref> if the <tref>JSON object</tref> contains a <code>@datatype</code> key
2592-
after performing <a href="#iri-expansion">IRI Expansion</a> on the specified<code>@datatype</code>.
2590+
as a <tref>typed literal</tref> if the <tref>JSON object</tref> contains a <code>@type</code> key
2591+
after performing <a href="#iri-expansion">IRI Expansion</a> on the specified<code>@type</code>.
25932592
</li>
25942593
<li>
25952594
otherwise, as a <tref>plain literal</tref>. If the <tref>JSON object</tref> contains

spec/latest/json-ld-syntax/index.html

Lines changed: 23 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -413,11 +413,10 @@ <h2>Syntax Tokens and Keywords</h2>
413413

414414
<dl>
415415
<dt><code>@context</code></dt><dd>Used to set the <tref>local context</tref>.</dd>
416-
<dt><code>@datatype</code></dt><dd>Used to specify the datatype for a literal.</dd>
417416
<dt><code>@id</code></dt><dd>Sets the active subject.</dd>
418417
<dt><code>@language</code></dt><dd>Used to specify the language for a literal.</dd>
419418
<dt><code>@literal</code></dt><dd>Used to specify a literal value.</dd>
420-
<dt><code>@type</code></dt><dd>Used to set the type of the active subject.</dd>
419+
<dt><code>@type</code></dt><dd>Used to set the type of the active subject or the datatype of a literal.</dd>
421420
<dt><code>:</code></dt><dd>The separator for JSON keys and values that use the <tref>prefix</tref> mechanism.</dd>
422421
</dl>
423422
</section>
@@ -856,7 +855,7 @@ <h2>IRIs</h2>
856855
"@context": {
857856
...
858857
"homepage": {
859-
"@id": "http://xmlns.com/foaf/0.1/homepage", "@datatype": "@id"
858+
"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"
860859
}
861860
...
862861
}****
@@ -945,7 +944,6 @@ <h2>Specifying the Type</h2>
945944
<http://xmlns.com/foaf/0.1/Person> .
946945
-->
947946
</pre>
948-
949947
</section>
950948

951949
<section>
@@ -1006,22 +1004,22 @@ <h2>Typed Literals</h2>
10061004
</p>
10071005

10081006
<ol>
1009-
<li>By utilizing the <code>@datatype</code> keyword when defining a <tref>term</tref> within a
1007+
<li>By utilizing the <code>@type</code> keyword when defining a <tref>term</tref> within a
10101008
<code>@context</code> section.</li>
10111009
<li>By utilizing the expanded form for specifying objects.</li>
10121010
<li>By using a native JSON datatype.</li>
10131011
</ol>
10141012

1015-
<p>The first example uses the <code>@datatype</code> keyword to express a typed literal:</p>
1013+
<p>The first example uses the <code>@type</code> keyword to express a typed literal:</p>
10161014

10171015
<pre class="example" data-transform="updateExample">
10181016
<!--
10191017
{
10201018
****"@context": {
1021-
"modified":
1022-
{
1019+
"xsd": "http://www.w3.org/2001/XMLSchema#",
1020+
"modified": {
10231021
"@id": "http://purl.org/dc/terms/modified",
1024-
"@datatype": "http://www.w3.org/2001/XMLSchema#dateTime"
1022+
"@type": "xsd:dateTime"
10251023
}
10261024
}****
10271025
...
@@ -1037,10 +1035,9 @@ <h2>Typed Literals</h2>
10371035
<!--
10381036
{
10391037
...
1040-
"modified": ****
1041-
{
1038+
"modified": ****{
10421039
"@literal": "2010-05-29T14:17:39+02:00",
1043-
"@datatype": "dateTime"
1040+
"@type": "xsd:dateTime"
10441041
}****
10451042
...
10461043
}
@@ -1075,6 +1072,13 @@ <h2>Typed Literals</h2>
10751072
-->
10761073
</pre>
10771074

1075+
<p class="note">
1076+
The <code>@type</code> keyword is also used to associate a type with an object. Although the same keyword
1077+
is used in both places, the concept of object type and literal datatype are, in fact, different. This is similar
1078+
to object-oriented programming languages where both scalar and structured types use the same class inheritance
1079+
mechanism, even though scalar types and structured types are inherently different.
1080+
</p>
1081+
10781082
</section>
10791083

10801084
<section>
@@ -1189,7 +1193,7 @@ <h2>Lists</h2>
11891193
<p>
11901194
This describes the use of this <tref>array</tref> as being ordered, and order is maintained through normalization
11911195
and RDF conversion as described in [[JSON-LD-API]]. If every use of a given multi-valued property is a list, this
1192-
may be abbreviated by adding an <code>@datatype</code> <tref>coercion</tref>:
1196+
may be abbreviated by adding an <code>@type</code> <tref>coercion</tref>:
11931197
</p>
11941198
<pre class="example" data-transform="updateExample">
11951199
<!--
@@ -1562,7 +1566,7 @@ <h2>Automatic Typing</h2>
15621566
// The following value is automatically converted to a type of xsd:double as well
15631567
"space:astronomicUnits": ****6.5e73****,
15641568
// The following value should never be converted to a language-native type
1565-
"measure:stones": ****{ "@literal": "4.8", "@datatype": "xsd:decimal" }****,
1569+
"measure:stones": ****{ "@literal": "4.8", "@type": "xsd:decimal" }****,
15661570
// This value is automatically converted to having a type of xsd:integer
15671571
"chem:protons": ****12****,
15681572
// This value is automatically converted to having a type of xsd:boolean
@@ -1602,13 +1606,13 @@ <h2>Type Coercion</h2>
16021606
properly typed RDF data.</p>
16031607

16041608
<p>Type coercion is specified within an <a href="#expanded-term-definition">expanded term definition</a>
1605-
using the <code>@datatype</code> key. The values of this key represent datatype IRIs and MUST take the form of
1609+
using the <code>@type</code> key. The values of this key represent datatype IRIs and MUST take the form of
16061610
<tref>term</tref>, <tref>prefix</tref>:suffix, absolute IRI or the keyword <code>@id</code>. Specifying
16071611
<code>@id</code> indicates that within the body of a JSON-LD document, string values of keys coerced as
16081612
<code>@id</code> are to be interpreted as <tref>IRI</tref>s, or labeled nodes and are subject to IRI expansion.</p>
16091613

16101614
<p><tref title="term">Terms</tref> or <tref title="prefix">prefixes</tref> used as the value of a
1611-
<code>@datatype</code> key MAY be defined within the same context.</p>
1615+
<code>@type</code> key MAY be defined within the same context.</p>
16121616

16131617
<p>The example below demonstrates how a JSON-LD author can coerce values to
16141618
<tref>plain literal</tref>s, <tref>typed literal</tref>s, IRIs and lists.</p>
@@ -1621,8 +1625,8 @@ <h2>Type Coercion</h2>
16211625
"rdf": "http://www.w3.org/1999/02/22-rdf-syntax-ns#",
16221626
"xsd": "http://www.w3.org/2001/XMLSchema#",
16231627
"name": "http://xmlns.com/foaf/0.1/name",
1624-
"age": ****{"@id": "http://xmlns.com/foaf/0.1/age", "@datatype": "xsd:integer"}****,
1625-
"homepage": ****{"@id": "http://xmlns.com/foaf/0.1/homepage", "@datatype": "@id"}****
1628+
"age": ****{"@id": "http://xmlns.com/foaf/0.1/age", "@type": "xsd:integer"}****,
1629+
"homepage": ****{"@id": "http://xmlns.com/foaf/0.1/homepage", "@type": "@id"}****
16261630
},
16271631
"name": "John Smith",
16281632
"age": ****"41"****,
@@ -1966,7 +1970,7 @@ <h3>Microformats</h3>
19661970
"@context":
19671971
{
19681972
"vcard": "http://microformats.org/profile/hcard#vcard",
1969-
"url": {"@id": "http://microformats.org/profile/hcard#url", "@datatype": "@id"},
1973+
"url": {"@id": "http://microformats.org/profile/hcard#url", "@type": "@id"},
19701974
"fn": "http://microformats.org/profile/hcard#fn"
19711975
},
19721976
"@id": "_:bnode1",

0 commit comments

Comments
 (0)