* new section on alternatives ldpatch
authorAlexandre Bertails <bertails@gmail.com>
Tue, 19 Aug 2014 22:43:37 -0400
branchldpatch
changeset 745 4c0cabfd1189
parent 728 b59441421b0f
child 746 66030a2d0f9f
* new section on alternatives
* changed the slice operator s/:/../
* changed StepBackward to use a caret s/-/^/
* documented ISSUE-100
* fixed some typos and links
ldpatch.html
--- a/ldpatch.html	Sun Jul 27 22:12:55 2014 -0400
+++ b/ldpatch.html	Tue Aug 19 22:43:37 2014 -0400
@@ -162,6 +162,41 @@
           preProcess: [ preProc ]
       };
     </script>
+    <style type="text/css">
+.atrisk {
+  padding:    1em;
+  margin: 1em 0em 0em;
+  border: 1px solid #f00;
+  background: #ffc;
+}
+.atrisktext {
+  /* content:    "Feature At Risk"; */
+  display:    block;
+  width:  150px;
+  margin: -1.5em 0 0.5em 0;
+  font-weight:    bold;
+  border: 1px solid #f00;
+  background: #fff;
+  padding:    3px 1em;
+}
+
+div.rule {padding-top: 1em;}
+div.ldp-issue {
+  border-color: #E05252;
+  background: #FBE9E9;
+  padding: 0.5em;
+  margin: 1em 0;
+  position: relative;
+  clear: both;
+  border-left-width: .5em;
+  border-left-style: solid;
+}
+div.ldp-issue-title {
+  color: #E05252;
+  padding-right: 1em;
+  min-width: 7.5em;
+}
+    </style>
   </head>
   <body>
     <section id='abstract'>
@@ -183,39 +218,33 @@
 Linked Data "describes a method of publishing structured data so that it can be interlinked and become more useful. It builds upon standard Web technologies such as HTTP, RDF and URIs, but rather than using them to serve web pages for human readers, it extends them to share information in a way that can be read automatically by computers. This enables data from different sources to be connected and queried." (source Wikipedia).
       </p>
       <p>
-This document defines the Linked Data Patch Format (LD Patch), a format for describing changes to apply to Linked Data. It is suitable for use with HTTP PATCH [@@RFC5789], a method to perform partial modifications to Web resources. The "text/ldpatch" media type is used to identify such LD Patch documents.
+This document defines the Linked Data Patch Format (LD Patch), a format for describing changes to apply to Linked Data. It is suitable for use with <a href="http://tools.ietf.org/html/rfc5789">HTTP PATCH</a>, a method to perform partial modifications to Web resources. The "text/ldpatch" media type is used to identify such LD Patch documents.
       </p>
       <p>
 An instance of the LD Patch language (or LD Patch document) defines a list of operations to be performed against an RDF Graph, namely the addition or removal of RDF triples in this graph.
       </p>
 
       <p id="relation-sparql-update">
-        The LD Patch format described in this document should be seen as an "assembly language" for updating RDF Graphs. It is the intention to confine its expressive power to an RDF diff with minimal support for blank nodes. For more powerful operations on RDF Graphs and Quad Stores, the LDP WG recommends the reader to consider <a href="http://www.w3.org/TR/sparql11-update/">SPARQL Update</a>.
+        The LD Patch format described in this document should be seen as an "assembly language" for updating <a href="http://www.w3.org/TR/rdf11-concepts/#section-rdf-graph">RDF Graphs</a>. It is the intention to confine its expressive power to an RDF diff with <a href="#pathological-graph">minimal support for blank nodes</a> and <code>rdf:List</code> manipulations. For more powerful operations on RDF Graphs and Quad Stores, the LDP WG recommends the reader to consider <a href="http://www.w3.org/TR/sparql11-update/">SPARQL Update</a>.
       </p>
 
-      <!--p>
-In fact, LD Patch _could_ have been defined as a subset of SPARQL
-Update, even though the group had decided not to depend on SPARQL as a
-whole. This option was considered and we decided it did not provide
-any substancial advantage, while bringing some caveats: a compatible
-concrete syntax would have actually shared a lot of similar production
-rules than in this proposal, as most would be similar to Turtle's; but
-unlike SPARQL, the runtime semantics does **not** need to depend on
-(intermediate) result sets, which simplifies implementations and
-removes [incidental
-complexity](https://en.wikipedia.org/wiki/Accidental_complexity). In
-summary, the only advantage would have been to have a familiar syntax
-for those coming from SPARQL, but with a different runtime semantics
-even, which could have been confusing, even if compatible.
+      <h2 id="considered-alternatives">Considered alternatives</h2>
 
-Furthermore SPARL has no built-in support for RDF collections, which
-makes them cumbersome to handle with that language (or any subset of
-it), all the more that RDF collections make an intensive use of blank
-nodes. We made the choice to provide opertions dedicated to RDF
-collections, both for easing their manipulation and for opening the
-way to specific optimizations in RDF stores that treat them specially.
+      <p>
+	  While exploring solutions for a <a href="http://www.w3.org/TR/ldp/#h4_ldpr-HTTP_PATCH">PATCH format for the Linked Data Platform</a>, the LDP WG also considered the following approaches:
+      </p>
 
-      </p-->
+      <ul>
+	  <li><a href="http://afs.github.io/rdf-patch/">RDF Patch</a></li>
+	  <li><a href="http://www.w3.org/TR/sparql11-http-rdf-update/#http-patch">SPARQL 1.1 Update</a></li>
+	  <li><a href="http://www.w3.org/2001/sw/wiki/TurtlePatch">TurtlePatch</a></li>
+	  <li><a href="http://www.w3.org/2012/ldp/wiki/LDP_PATCH_Proposals#EricP.27s_proposal">SPARQL Patch</a></li>
+      </ul>
+
+      <p>
+	  As for LD Patch, those come with their pros and cons: support for blank nodes, <a href="http://www.w3.org/2013/meeting/ldp/2014-04-17#line0243">skolemization</a>, runtime complexity, <a href="#pathological-graph">pathological graphs</a>, <code>rdf:List</code> manipulations... Even though the group decided to <a href="http://www.w3.org/2013/meeting/ldp/2014-04-17#resolution_2">go ahead</a> with the format discussed in this document, feedback from users and implementers is more that welcome.
+      </p>
+
 
       <h2 id="intro-example">Example</h2>
 
@@ -261,12 +290,12 @@
 Delete &lt;#&gt; profile:first_name "Tim" .
 Add    &lt;#&gt; profile:first_name "Timothy" .
 
-UpdateList &lt;#&gt; ex:preferredLanguages 1&gt;2 ( "fr-CH" ) .
+UpdateList &lt;#&gt; ex:preferredLanguages 1..2 ( "fr-CH" ) .
 
 Bind ?event &lt;#&gt; /schema:attendee[/schema:url = &lt;https://www.w3.org/2012/ldp/wiki/F2F5&gt;]  .
 Add ?event rdf:type schema:Event .
 
-Bind ?ted &lt;http://conferences.ted.com/TED2009/&gt; /-schema:url! .
+Bind ?ted &lt;http://conferences.ted.com/TED2009/&gt; /^schema:url! .
 Delete ?ted schema:startDate "2009-02-04".
 Add ?ted schema:location _:loc .
 Add _:loc schema:name "Long Beach, California" .
@@ -332,7 +361,7 @@
       <section id="node-matching-semantics">
         <h2><tdef>Node matching semantics</tdef></h2>
         <p>
-LD Patch borrows much of its syntax to Turtle (@@@ref) and SPARQL (@@@ref) for describing nodes. IRIs (either abbreviated or not) and literals represent the corresponding node in the graph being patched. Blank nodes, on the other hand, pose a problem, as they have no global identifier. Indeed, blank node identifiers have their scope limited to the document in which they appear. As a consequence, whenever a blank node identifiers appears in an LD Patch document, it is understood to denote a <em>fresh</em> blank node, that needs to be created in the patched RDF graph. They cannot interfere with existing blank nodes in the graph.
+LD Patch borrows much of its syntax to <a href="http://www.w3.org/TR/turtle/">Turtle</a> and <a href="http://www.w3.org/TR/sparql11-query/">SPARQL</a> for describing nodes. IRIs (either abbreviated or not) and literals represent the corresponding node in the graph being patched. Blank nodes, on the other hand, pose a problem, as they have no global identifier. Indeed, blank node identifiers have their scope limited to the document in which they appear. As a consequence, whenever a blank node identifiers appears in an LD Patch document, it is understood to denote a <em>fresh</em> blank node, that needs to be created in the patched RDF graph. They cannot interfere with existing blank nodes in the graph.
         </p>
         <p>
           In order to be able to address blank nodes already present in the graph, LD Patch has two mechanisms: <tref>Bind</tref>ing a variable to a blank node reachable with a <tref>path expression</tref>, and <tref>UpdateList</tref> to deal with those blank nodes that constitute RDF collections. There are cases where those mechanisms will not be able to unambiuously adress a given blank node, but those cases are deemed <a href="#pathological-graph">pathological</a>, and out of the scope of this specification.
@@ -391,7 +420,7 @@
         </p>
         <ul>
           <li>A <tref>StepForward</tref> is defined by a URI, and consists in following outgoing arcs having that URI as their predicate.</li>
-          <li>A <tref>StepBackward</tref> is defined by a URI preceded with the minus ("-") sign, and consists in following incoming arcs having that URI as their predicate.</li>
+          <li>A <tref>StepBackward</tref> is defined by a URI preceded with the caret ("<code>^</code>") sign, and consists in following incoming arcs having that URI as their predicate.</li>
           <li>A <tref>StepAt</tref> is defined by an integer <i>n</i>, and consists in following <i>n</i> <code>rdf:rest</code> arcs and one <code>rdf:first</code> arc in order to reach the corresponding member of an RDF collection.</li>
         </ul>
         <p>
@@ -401,9 +430,9 @@
 A Path may also contains <tref>Constraint</tref>s, which are of two kinds:
         </p>
         <ul>
-          <li>A unicity constraint, described by the <em>bang</em> ("!") character, ensures that the result of the path so far contains exactly one node.</li>
-          <li>A <tref>filter</tref>, consisting of a path in square brackets ("[", "]"), keeps only from the matching nodes so far those that “satisfy” the enclosed path, i.e. those from which the enclosed path reaches at least one node.</li>
-          <li>Additionally, the path in a <tref>filter</tref> can be followed by the equal ("=") sign and a <tref>Value</tref>. In that case, only the node for which that particular value is reached through the enclosed path are kept.</li>
+          <li>A unicity constraint, described by the <em>bang</em> ("<code>!</code>") character, ensures that the result of the path so far contains exactly one node.</li>
+          <li>A <tref>filter</tref>, consisting of a path in square brackets ("<code>[</code>", "<code>]</code>"), keeps only from the matching nodes so far those that “satisfy” the enclosed path, i.e. those from which the enclosed path reaches at least one node.</li>
+          <li>Additionally, the path in a <tref>filter</tref> can be followed by the equal ("<code>=</code>") sign and a <tref>Value</tref>. In that case, only the node for which that particular value is reached through the enclosed path are kept.</li>
         </ul>
         <p>
 The path below (taken from our running example) will look for all the events attended by the starting node, and keep only those  having <code>&lt;http://conferences.ted.com/TED2009/&gt;</code> as their URL.
@@ -411,6 +440,12 @@
 /schema:attendee[/schema:url = &lt;http://conferences.ted.com/TED2009/&gt;]
         </pre>
         </p>
+
+	<div class="ldp-issue">
+	    <div class="ldp-issue-title"><a href="http://www.w3.org/2012/ldp/track/issues/100">ISSUE-100</a></div>
+	    Should ld-patch use a slash like sparql does, instead of as it currently does?
+	</div>
+
       </section>
 
       <section id="bind-statement">
@@ -425,7 +460,7 @@
 The Bind operation is defined by three components: <tref>Var</tref>, <tref>Value</tref> and <tref>Path</tref>, the last component being optional.
         </p>
         <p>
-<tref>Var</tref> contains a unique name for the new variable. Variables are prefixed by "?"; the "?" character is not part of the variable name.
+<tref>Var</tref> contains a unique name for the new variable. Variables are prefixed by "<code>?</code>"; the "<code>?</code>" character is not part of the variable name.
         </p>
         <p>
 <tref>Value</tref> is the RDF Term that will be used as starting point when following the path expression.
@@ -444,7 +479,7 @@
 
 Add ?event rdf:type schema:Event .
         </pre>
-When the third component is an <tref>Object</tref>, then a single statement will be added. On the other hand, when it is a <tref>List</tref>, all the intermediate blank nodes and corresponding statements will be added to construct a well formed RDF collection (@@@ref to RDF-Schema) (in addition to the triple with the given <tref>Subject</tref>, <tref>Predicate</tref> and that collection as the object).
+When the third component is an <tref>Object</tref>, then a single statement will be added. On the other hand, when it is a <tref>List</tref>, all the intermediate blank nodes and corresponding statements will be added to construct a well formed <a href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a> (in addition to the triple with the given <tref>Subject</tref>, <tref>Predicate</tref> and that collection as the object).
         </p>
       </section>
 
@@ -463,9 +498,9 @@
       <section id="update-list-statement">
         <h2><tdef>UpdateList</tdef></h2>
         <p>
-The UpdateList operation is used to update the members of an RDF collection (@@@ref). That collection is supposed to be the object of a triple, specified by its <tref>Subject</tref> and <tref>Predicate</tref>. A <tref>Slice</tref> specification then describes which members (if any) of the collections are affected by the operation, and then a <tref>List</tref> of new members is provided. In the example below, UpdateList is used to replace the second member of a collection by the literal "fr-CH".
+The UpdateList operation is used to update the members of an <a href="http://www.w3.org/TR/rdf-schema/#ch_collectionvocab">RDF collection</a>. That collection is supposed to be the object of a triple, specified by its <tref>Subject</tref> and <tref>Predicate</tref>. A <tref>Slice</tref> specification then describes which members (if any) of the collections are affected by the operation, and then a <tref>List</tref> of new members is provided. In the example below, UpdateList is used to replace the second member of a collection by the literal "fr-CH".
         <pre class='example'>
-UpdateList &lt;#&gt; ex:preferredLanguages 1>2 ( "fr-CH" ) .
+UpdateList &lt;#&gt; ex:preferredLanguages 1..2 ( "fr-CH" ) .
         </pre>
         </p>
         <p>
@@ -473,7 +508,7 @@
         </p>
 
         <p>
-In LD Patch, a slice is described by two positive integers separated by ">". The second integer can be omitted, in that case it denotes the end of the list. If both integers are omitted (i.e. ">" alone), this denotes by convention the empty slice at the end of the list. Indexes start at 0.
+In LD Patch, a slice is described by two positive integers separated by "<code>..</code>". The second integer can be omitted, in that case it denotes the end of the list. If both integers are omitted (i.e. "<code>..</code>" alone), this denotes by convention the empty slice at the end of the list. Indexes start at 0.
         </p>
 
         <p>
@@ -481,7 +516,7 @@
         </p>
 
         <pre class='example'>
-UpdateList &lt;#&gt; ex:preferredLanguages > ( "fr-CH" ) .
+UpdateList &lt;#&gt; ex:preferredLanguages .. ( "fr-CH" ) .
         </pre>
 
         <p>
@@ -489,7 +524,7 @@
         </p>
 
         <pre class='example'>
-UpdateList &lt;#&gt; ex:preferredLanguages 2> ( "fr-CH" ) .
+UpdateList &lt;#&gt; ex:preferredLanguages 2.. ( "fr-CH" ) .
         </pre>
 
 
@@ -518,10 +553,10 @@
 <tdef>List</tdef> ::= '(' <tref>Object</tref>* ')'
 
 <tref>Path</tref> ::= ( <tref>Step</tref> | <tref>Constraint</tref> )*
-<tdef>Step</tdef> ::= '/' ( '-' <tref>iri</tref> | <tref>iri</tref> | <tref>INDEX</tref> )
+<tdef>Step</tdef> ::= '/' ( '^' <tref>iri</tref> | <tref>iri</tref> | <tref>INDEX</tref> )
 <tdef>Constraint</tdef> ::= '[' <tref>Path</tref> ( '=' <tref>Value</tref> )? ']' | '!'
 
-<tdef>Slice</tdef> ::= <tref>INDEX</tref>? '&gt;' <tref>INDEX</tref>?
+<tdef>Slice</tdef> ::= <tref>INDEX</tref>? '..' <tref>INDEX</tref>?
 <tdef>INDEX</tdef> ::= [0-9]+
 
 // copied from SPARQL