--- a/spec/latest/json-ld-syntax/index.html Tue Mar 12 17:35:08 2013 +0100
+++ b/spec/latest/json-ld-syntax/index.html Tue Mar 12 18:20:17 2013 +0100
@@ -861,24 +861,18 @@
<h2>Compact IRIs</h2>
<p>A <tdef>compact IRI</tdef> is a way of expressing an <tref>IRI</tref>
- using a <em>prefix</em> and <em>suffix</em> separated by a colon (<code>:</code>) which is
- similar to the <cite><a href="http://www.w3.org/TR/rdfa-core/#s_curies">CURIE Syntax</a></cite>
- in [[RDFA-CORE]]. The <tdef>prefix</tdef> is a <tref>term</tref> taken from the
+ using a <em>prefix</em> and <em>suffix</em> separated by a colon (<code>:</code>).
+ The <tdef>prefix</tdef> is a <tref>term</tref> taken from the
<tref>active context</tref> and is a short string identifying a
- particular <tref>IRI</tref> in a JSON-LD document.
- For example, the prefix <code>foaf</code> may be used as a short
- hand for the Friend-of-a-Friend vocabulary, which is identified using
- the IRI <code>http://xmlns.com/foaf/0.1/</code>. A developer may append
+ particular <tref>IRI</tref> in a JSON-LD document. For example, the
+ prefix <code>foaf</code> may be used as a short hand for the
+ Friend-of-a-Friend vocabulary, which is identified using the <tref>IRI</tref>
+ <code>http://xmlns.com/foaf/0.1/</code>. A developer may append
any of the FOAF vocabulary terms to the end of the prefix to specify a short-hand
version of the <tref>absolute IRI</tref> for the vocabulary term. For example,
- <code>foaf:name</code> would be expanded out to the IRI
+ <code>foaf:name</code> would be expanded to the IRI
<code>http://xmlns.com/foaf/0.1/name</code>.</p>
- <p><tref title="prefix">Prefixes</tref> are expanded when the form of the value
- is a <tref>compact IRI</tref> represented as a <code>prefix:suffix</code>
- combination, and the prefix matches a <tref>term</tref> defined within the
- <tref>active context</tref>:</p>
-
<pre class="example" data-transform="updateExample"
title="Prefix expansion">
<!--
@@ -888,69 +882,51 @@
"****foaf****": "****http://xmlns.com/foaf/0.1/****"
...
},
+ "@type": "****foaf:Person****"
"****foaf:name****": "Dave Longley",
...
}
-->
</pre>
- <p><code>foaf:name</code> above will automatically expand out to the IRI
- <code>http://xmlns.com/foaf/0.1/name</code>.</p>
-
- <p>Terms are interpreted as <tref title="compact iri">compact IRIs</tref> if they contain at least one
- colon and the first colon is not followed by two slashes (<code>//</code>, as in
- <code>http://example.com</code>). To generate the full <tref>IRI</tref>,
- the value is first split into a <em>prefix</em> and <em>suffix</em> at the first
- occurrence of a colon (<code>:</code>). If the <tref>active context</tref>
- contains a term mapping for <em>prefix</em>, an IRI is generated by
- prepending the mapped <em>prefix</em> to the (possibly empty) <em>suffix</em>
- using textual concatenation. If no prefix mapping is defined, the value is interpreted
- as an <tref>absolute IRI</tref>. If the prefix is an underscore
- (<code>_</code>), the IRI remains unchanged.</p>
- <p>Consider the following example:</p>
-
- <pre class="example" data-transform="updateExample"
- title="Compact IRIs">
- <!--
- {
- "@context":
- {
- ****"dc": "http://purl.org/dc/elements/1.1/",****
- ****"ex": "http://example.org/vocab#"****
- },
- "@id": "http://example.org/library/the-republic",
- "@type": ****"ex:Book"****,
- ****"dc:creator"****: "Plato",
- ****"dc:title"****: "The Republic"
- }
- -->
- </pre>
-
- <p>In this example, two different vocabularies are referred to using prefixes.
- Those prefixes are then used as type and property values using the compact
- IRI <code>prefix:suffix</code> notation.</p>
+ <p>In the example above, <code>foaf:name</code> expands to the <tref>IRI</tref>
+ <code>http://xmlns.com/foaf/0.1/name</code> and <code>foaf:Person</code> expands
+ to <code>http://xmlns.com/foaf/0.1/Person</code>.</p>
+
+ <p><tref title="prefix">Prefixes</tref> are expanded when the form of the value
+ is a <tref>compact IRI</tref> represented as a <code>prefix:suffix</code>
+ combination, the <em>prefix</em> matches a <tref>term</tref> defined within the
+ <tref>active context</tref>, and the <em>suffix</em> does not begin with two
+ slashes (<code>//</code>). The <tref>compact IRI</tref> is expanded by
+ concatenating the <tref>IRI</tref> mapped to the <em>prefix</em> to the (possibly empty)
+ <em>suffix</em>. If the <em>prefix</em> is not defined in the <tref>active context</tref>,
+ or the suffix begins with two slashes (such as in <code>http://example.com</code>),
+ the value is interpreted as <tref>absolute IRI</tref> instead. If the prefix is an
+ underscore (<code>_</code>), the value is interpreted as <tref>blank node identifier</tref>
+ instead.</p>
+
<p>It's also possible to use compact IRIs within the context as shown in the
following example:</p>
<pre class="example" data-transform="updateExample"
title="Using vocabularies">
-<!--
-{
- "@context":
+ <!--
{
- "xsd": "http://www.w3.org/2001/XMLSchema#",
- ****"foaf": "http://xmlns.com/foaf/0.1/"****,
- ****"foaf:homepage"****: { "@type": "@id" },
- "picture": { "@id": ****"foaf:depiction"****, "@type": "@id" }
- },
- "@id": "http://me.markus-lanthaler.com/",
- "@type": "foaf:Person",
- "foaf:name": "Markus Lanthaler",
- "foaf:homepage": "http://www.markus-lanthaler.com/",
- "picture": "http://twitter.com/account/profile_image/markuslanthaler"
-}
--->
+ "@context":
+ {
+ "xsd": "http://www.w3.org/2001/XMLSchema#",
+ ****"foaf": "http://xmlns.com/foaf/0.1/"****,
+ ****"foaf:homepage"****: { "@type": "@id" },
+ "picture": { "@id": ****"foaf:depiction"****, "@type": "@id" }
+ },
+ "@id": "http://me.markus-lanthaler.com/",
+ "@type": "foaf:Person",
+ "foaf:name": "Markus Lanthaler",
+ "foaf:homepage": "http://www.markus-lanthaler.com/",
+ "picture": "http://twitter.com/account/profile_image/markuslanthaler"
+ }
+ -->
</pre>
</section>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0067-in.jsonld Tue Mar 12 18:20:17 2013 +0100
@@ -0,0 +1,8 @@
+{
+ "@context": {
+ "http": "http://example.com/this-prefix-would-overwrite-all-http-iris"
+ },
+ "@id": "http://example.org/node1",
+ "@type": "http://example.org/type",
+ "http://example.org/property": "all these IRIs remain unchanged because they are interpreted as absolute IRIs"
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0067-out.jsonld Tue Mar 12 18:20:17 2013 +0100
@@ -0,0 +1,9 @@
+[
+ {
+ "@id": "http://example.org/node1",
+ "@type": ["http://example.org/type"],
+ "http://example.org/property": [
+ { "@value": "all these IRIs remain unchanged because they are interpreted as absolute IRIs" }
+ ]
+ }
+]
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0068-in.jsonld Tue Mar 12 18:20:17 2013 +0100
@@ -0,0 +1,8 @@
+{
+ "@context": {
+ "_": "http://example.com/this-prefix-would-overwrite-all-blank-node-identifiers"
+ },
+ "@id": "_:node1",
+ "@type": "_:type",
+ "_:property": "all these IRIs remain unchanged because they are interpreted as blank node identifiers"
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/expand-0068-out.jsonld Tue Mar 12 18:20:17 2013 +0100
@@ -0,0 +1,9 @@
+[
+ {
+ "@id": "_:b0",
+ "@type": ["_:b1"],
+ "_:b2": [
+ { "@value": "all these IRIs remain unchanged because they are interpreted as blank node identifiers" }
+ ]
+ }
+]
--- a/test-suite/tests/expand-manifest.jsonld Tue Mar 12 17:35:08 2013 +0100
+++ b/test-suite/tests/expand-manifest.jsonld Tue Mar 12 18:20:17 2013 +0100
@@ -338,6 +338,16 @@
"name": "Use @vocab to expand keys in reverse-maps",
"input": "expand-0066-in.jsonld",
"expect": "expand-0066-out.jsonld"
+ }, {
+ "@type": ["test:TestCase", "jld:ExpandTest"],
+ "name": "prefix:suffix values are not interpreted as compact IRIs if suffix begins with two slashes",
+ "input": "expand-0067-in.jsonld",
+ "expect": "expand-0067-out.jsonld"
+ }, {
+ "@type": ["test:TestCase", "jld:ExpandTest"],
+ "name": "prefix:suffix values are not interpreted as compact IRIs if prefix is an underscore",
+ "input": "expand-0068-in.jsonld",
+ "expect": "expand-0068-out.jsonld"
}
]
}