class: center, middle # Linked Data Patch Format Alexandre Bertails Pierre-Antoine Champin Andrei Sambra https://dvcs.w3.org/hg/ldpwg/raw-file/ldpatch/ldpatch.html --- # background ## STRAWPOLL http://www.w3.org/2013/meeting/ldp/2014-04-17#line0243 I'd rather have a solution that (a) doesn't address certain pathological graphs, or (b) requires the server to maintain Skolemization maps Result: (a) >> (b) ## RESOLVED http://www.w3.org/2013/meeting/ldp/2014-04-17#resolution_2 We agree to draft a Linked Data Patch Format, along the lines of Pierre-Antoine's proposal --- # in a nutshell * add/delete S P O * **no** direct reference to graph's bnodes (skolemization) * can traverse graph to find bnodes * node binding * special support for rdf:list * not really a language, more like a **diff on steroid** ## also * HTTP PATCH * no partial application (cf. [rfc5789](http://tools.ietf.org/html/rfc5789)) --- # prefixes ## syntax ``` @prefix rdf:
. @prefix schema:
. @prefix profile:
. @prefix ex:
. ``` ## semantics * as in Turtle * handled during parsing (to avoid prefixed names in the model) --- # add/delete triples ## syntax ``` Delete <#> profile:first_name "Tim" . Add <#> profile:first_name "Timothy" . ``` ## semantics obvious one --- # path expression ## syntax ``` /schema:attendee[/schema:url =
]!/schema:name ``` ## 4 actions * move forward/backward: `/` or `/` followed by `-` negative URI * restrict the current set of nodes with a "such that" predicate: `[subpath with optional constraint]` * make sure that the current set of nodes as exactly one element: `!` ## semantics * applied to a starting node in a graph, a path returns a set of nodes * applied from left to right, and recursively in a constraint (applied to the current nodes) * the constraint does not try to be smart: **pure** equality * no constraint means that at least one node could be found --- # node binding ## syntax ``` Bind ?event <#> /schema:attendee[/schema:url =
] . ``` ## semantics * binds the result of the application of the path to a named variable * the final set of nodes must be restricted to a single element (implicit `!`) * the bound variable can be re-used in following `Add`, `Delete`, `UpdateList` statements * can be overriden --- # UpdateList ## syntax replace list between indexes 1 and 2 ``` UpdateList <#> ex:preferredLanguages 1>2 ( "fr-CH" ) . ``` replace everything after index 1 ``` UpdateList <#> ex:preferredLanguages 1> ( "fr-CH" ) . ``` append ``` UpdateList <#> ex:preferredLanguages > ( "fr-CH" ) . ``` ## semantics * replace a slice of a list with a new list * touches only the **structure** of the list (`rdf:first` and `rdf:rest`) --- # the spec ## introduction ## concrete syntax * an LD Patch is a list of [statements](https://en.wikipedia.org/wiki/Statement_%28computer_science%29) * `Add`, `Delete`, `Bind`, `UpdateList` * most of the syntax taken from Turtle, and a bit of SPARQL * not written in stone ## abstract syntax * same approach than in RDB2RDF Direct Mapping: expressed using Abstract Data Types * used to specify the model we can use in the operational semantics ## operational semantics * defines the meaning of each element from the model * relies on a state * the graph being modified * a map for the bound variables **almost ready**