Update processing of base IRI
authorMarkus Lanthaler <mark_lanthaler@gmx.net>
Wed, 08 May 2013 16:58:17 +0200
changeset 1641 f5ba6c83e92c
parent 1640 c88482343a48
child 1642 063c14bc4cf0
Update processing of base IRI

This addresses #223.
spec/latest/json-ld-api/index.html
spec/latest/json-ld/index.html
--- a/spec/latest/json-ld-api/index.html	Tue May 07 09:58:54 2013 -0400
+++ b/spec/latest/json-ld-api/index.html	Wed May 08 16:58:17 2013 +0200
@@ -850,7 +850,8 @@
         <tref>default language</tref> by processing three specific keywords:
         <code>@base</code>, <code>@vocab</code>, and <code>@language</code>.
         These are handled before any other keys in the <tref>local context</tref> because
-        they affect how the other keys are processed.</p>
+        they affect how the other keys are processed. Please note that <code>@base</code> is
+        ignored when processing remote contexts.</p>
 
       <p>Then, for every other key in <tref>local context</tref>, we update
         the <tref>term definition</tref> in <i>result</i>. Since
@@ -887,7 +888,12 @@
           <ol class="algorithm">
             <li>If <i>context</i> is <tref>null</tref>, set <i>result</i> to a
               newly-initialized <tref>active context</tref> and continue with the
-              next <i>context</i>.</li>
+              next <i>context</i>. The <tref>base IRI</tref> of the
+              <tref>active context</tref> is set to the IRI of the currently being processed
+              document (which might be different from the currently being processed context),
+              if available; otherwise to <tref>null</tref>. If set, the
+              <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
+              option of a <tref>JSON-LD API Implementation</tref> overrides the <tref>base IRI</tref>.</li>
             <li>If <i>context</i> is a <tref>string</tref>,
               <ol class="algorithm">
                 <li>Set <i>context</i> to the result of resolving <i>value</i> against
@@ -907,27 +913,23 @@
                   <code class="error"><a href="#idl-def-JsonLdErrorCode.recursive-context-inclusion">recursive context inclusion</a></code>
                   error has been detected and processing is aborted;
                   otherwise, add <i>context</i> to <i>remote contexts</i>.</li>
-                <li>Initialize <i>context no base</i> to the result of cloning the
-                  <tref>active context</tref>.</li>
-                <li>Remove the <tref>base IRI</tref> of <i>context no base</i>.</li>
-                <li>Dereference <i>context</i>. If the dereferenced document has no
+                <li>Dereference <i>context</i>. If <i>context</i> cannot be dereferenced, a
+                  <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-remote-context-failed">loading remote context failed</a></code>
+                  error has been detected and processing is aborted. If the dereferenced document has no
                   top-level <tref>JSON object</tref> with an <code>@context</code> member, an
                   <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-remote-context">invalid remote context</a></code>
                   has been detected and processing is aborted; otherwise,
                   set <i>context</i> to the value of that member.</li>
-                <li>Set <i>context</i> to the result of recursively calling this algorithm,
-                  passing <i>context no base</i> for <tref>active context</tref>,
+                <li>Set <i>result</i> to the result of recursively calling this algorithm,
+                  passing <i>result</i> for <tref>active context</tref>,
                   <i>context</i> for <tref>local context</tref>, and <i>remote contexts</i>.</li>
-                <li>If <i>context</i> has no <tref>base IRI</tref> but <i>result</i> does,
-                  set the <tref>base IRI</tref> of <i>context</i> to the one of
-                  <i>result</i>.</li>
-                <li>Overwrite <i>result</i> with <i>context</i> and continue with the
-                  next <i>context</i>.</li>
+                <li>Continue with the next <i>context</i>.</li>
               </ol>
             <li>If <i>context</i> is not a <tref>JSON object</tref>, an
               <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-local-context">invalid local context</a></code>
               error has been detected and processing is aborted.</li>
-            <li>If <i>context</i> has an <code>@base</code> key:
+            <li>If <i>context</i> has an <code>@base</code> key and <i>remote contexts</i> is empty, i.e., the currently
+              being processed context is not a remote context:
               <div class="issue atrisk" data-number="1" title="@base keyword">
                 <p class="atrisk-head">Note: This feature is
                   <a href="http://www.w3.org/2005/10/Process-20051014/tr#cfi">"at risk"</a> and may
@@ -948,8 +950,13 @@
                 <li>If <i>value</i> is <tref>null</tref>, remove the
                   <tref>base IRI</tref> of <i>result</i>.</li>
                 <li>Otherwise, if <i>value</i> is an <tref>absolute IRI</tref>,
-                  the <tref>base IRI</tref> of <i>result</i> is set to <i>value</i>.
-                  If it is not an <tref>absolute IRI</tref>, an
+                  the <tref>base IRI</tref> of <i>result</i> is set to <i>value</i>.</li>
+                <li>Otherwise, if <i>value</i> is a <tref>relative IRI</tref> and
+                  the <tref>base IRI</tref> of <i>result</i> is not <tref>null</tref>,
+                  set the <tref>base IRI</tref> of <i>result</i> to the result of
+                  resolving <i>value</i> against the current <tref>base IRI</tref>
+                  of <i>result</i>.</li>
+                <li>Otherwise, an
                   <code class="error"><a href="#idl-def-JsonLdErrorCode.invalid-base-IRI">invalid base IRI</a></code>
                   error has been detected and processing is aborted.</li>
               </ol>
@@ -3754,7 +3761,11 @@
             if the document cannot be parsed as JSON, reject the <i>future</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
-          <li>Initialize a new empty <tref>active context</tref>.</li>
+          <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
+            of the <tref>active context</tref> is set to the IRI of the currently being processed
+            document, if available; otherwise to <tref>null</tref>. If set, the
+            <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
+            overrides the <tref>base IRI</tref>.</li>
           <li>If an
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             has been passed, update the <tref>active context</tref> using the
@@ -3805,7 +3816,11 @@
             if the document cannot be parsed as JSON, reject the <i>future</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
-          <li>Initialize a new empty <tref>active context</tref>.</li>
+          <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
+            of the <tref>active context</tref> is set to the IRI of the currently being processed
+            document, if available; otherwise to <tref>null</tref>. If set, the
+            <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
+            overrides the <tref>base IRI</tref>.</li>
           <li>If an
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             has been passed, update the <tref>active context</tref> using the
@@ -3849,7 +3864,11 @@
             if the document cannot be parsed as JSON, reject the <i>future</i> passing an
             <code class="error"><a href="#idl-def-JsonLdErrorCode.loading-document-failed">loading document failed</a></code>
             error.</li>
-          <li>Initialize a new empty <tref>active context</tref>.</li>
+          <li>Initialize a new empty <tref>active context</tref>. The <tref>base IRI</tref>
+            of the <tref>active context</tref> is set to the IRI of the currently being processed
+            document, if available; otherwise to <tref>null</tref>. If set, the
+            <code class="idlMemberName"><a href="#widl-JsonLdOptions-compactArrays">compactArrays</a></code>
+            overrides the <tref>base IRI</tref>.</li>
           <li>If an
             <code class="idlMemberName"><a href="#widl-JsonLdOptions-expandContext">expandContext</a></code>
             has been passed, update the <tref>active context</tref> using the
--- a/spec/latest/json-ld/index.html	Tue May 07 09:58:54 2013 -0400
+++ b/spec/latest/json-ld/index.html	Wed May 08 16:58:17 2013 +0200
@@ -849,6 +849,12 @@
   }
   -->
   </pre>
+
+  <p>Setting <code>@base</code> to <tref>null</tref> will prevent
+    <tref title="relative IRI">relative IRIs</tref> to be expanded to
+    <tref title="absolute IRI">absolute IRIs</tref>.</p>
+
+  <p>Please note that the <code>@base</code> will be ignored if used in external contexts.</p>
 </section>
 
 <section class="informative">
@@ -3075,7 +3081,8 @@
     its value MUST have the lexical form described in [[!BCP47]] or be <tref>null</tref>.</p>
 
   <p>If the <tref>context definition</tref> has a <code>@base</code> key,
-    its value MUST be an <tref>absolute IRI</tref> or <tref>null</tref>.</p>
+    its value MUST be an <tref>absolute IRI</tref>, a <tref>relative IRI</tref>,
+    or <tref>null</tref>.</p>
 
   <div class="issue atrisk" data-number="1" title="@base keyword">
     <p class="atrisk-head">Note: This feature is