<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>RDF Editing on the Web</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Claus Stadler</string-name>
          <email>cstadler@informatik.uni-</email>
          <email>cstadler@informatik.unileipzig.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Michael Martin</string-name>
          <email>martin@informatik.uni-</email>
          <email>martin@informatik.unileipzig.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Natanael Arndt</string-name>
          <email>arndt@informatik.uni-</email>
          <email>arndt@informatik.unileipzig.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Jens Lehmann</string-name>
          <email>lehmann@informatik.uni-</email>
          <email>lehmann@informatik.unileipzig.de</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Department of Computer</institution>
          ,
          <addr-line>Science</addr-line>
          ,
          <institution>University of Leipzig</institution>
        </aff>
      </contrib-group>
      <fpage>96</fpage>
      <lpage>99</lpage>
      <abstract>
        <p>While several tools for simplifying the task of visualizing (SPARQL accessible) RDF data on the Web are available today, there is a lack of corresponding tools for exploiting standard HTML forms directly for RDF editing. The few related existing systems roughly fall in the categories of (a) applications that are not aimed at being reused as components, (b) form generators, which automatically create forms from a given schema { possibly derived from instance data { or (c) form template processors which create forms from a manually created speci cation. Furthermore, these systems usually come with their own widget library, which can only be extended by wrapping existing widgets. In this paper, we present the AngularJS-based Rdf Edit eXtension (REX) system, which facilitates the enhancement of standard HTML forms as well as many existing AngularJS widgets with RDF editing support by means of a set of HTML attributes. We demonstrate our system though the realization of several usage scenarios.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>lution is based on using the popular AngularJS framework2
to de ne a custom set of HTML attributes which add an
RDF context to form controls in the DOM-tree. While this
approach is similar to RDFa3, there are two fundamental
di erences: First, RDFa is intended for static annotation of
HTML documents, whereas our annotations are processed
by AngularJS and our framework at runtime based on the
applications' state. Second, RDFa is aligned with the HTML
standard, whereas our approach exploits concepts of
AngularJS and builds upon its abstractions, most prominently
the one introduced by ngModel 4 Also, a key
distinguishing feature that contrasts current related work is, that our
system does not introduce a widget framework of its own.
Instead, by building on the AngularJS framework and its
abstractions, many already available widgets can be re-used
directly without the need of wrapping.</p>
      <p>
        Our contributions in this paper are twofold: First, we present
the Rdf Edit eXtension system (REX), which makes HTML
forms RDF-aware using a set of custom HTML attributes.
Second, we devise several usage patterns of our system for
solving common problems related to RDF editing.
Our RDF editing system is implemented as a user interface
module as part of our Javascript S uite for S PARQL Access
(Jassa) library [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ]. The module is freely available on Github5
and is registered for use as a dependency with the popular
bower tool6 under the name jassa-ui-angular-edit.
Further, demos are available online7.
      </p>
      <p>The structure of this paper is as follows: In Section 2, we
introduce our REX approach and discuss its use in several
scenarios. A brief outline of use cases is given in Section 3. In
Section 4, we review existing approaches to RDF authoring
and presentation on the Web and discuss their strengths and
weaknesses. Finally, in Section 5 we conclude this paper.</p>
    </sec>
    <sec id="sec-2">
      <title>2https://angularjs.org/</title>
      <p>3http://www.w3.org/TR/rdfa-syntax/
4https://docs.angularjs.org/api/ng/directive/ng
Model
5https://github.com/GeoKnow/Jassa-UI-Angular/tree
/master/jassa-ui-angular-edit
6http://bower.io/
7http://js.geoknow.eu/demos/rex/</p>
      <sec id="sec-2-1">
        <title>2. RDF EDIT EXTENSIONS</title>
        <p>In this section we, explain our REX annotation system for
extending HTML forms with support for RDF editing. We
introduce our approach using a simple example, then explain
what types of data REX manages and nally we present
several patterns for solving common problems. Note, that our
annotations can also be used for retrieving data intended
for display. However, REX is focused on the support of
bidirectional mapping of values between an RDF graph and
the model of form controls. Thus, support for arbitrary
SPARQL queries and post-processing of result sets, such as
chosing the best label in regard to preferences on
vocabularies and languages, is not part of the core.</p>
        <p>It is important to understand, that AngularJS makes it
possible to annotate HTML form controls with ng-model="foo",
which declares a JavaScript variable foo as the model of the
control. When the user enters input, the model's value is
changed accordingly, and when the model changes,
AngularJS automatically updates the form control to re ect the
new state. Our approach is based on the introduction of a
set of annotations which give model values an RDF context.
In the subsequent sections we explain the REX attributes.</p>
      </sec>
      <sec id="sec-2-2">
        <title>2.1 Core HTML Attributes</title>
        <p>Consider the example in Listing 1. First of all, the
rexcontext is used to activate the REX system on a DOM
element and its descendants. The presence of the attribute
creates the rexContext object in the corresponding scope,
whose purpose is to keep track of (a) RDF values referenced
in form controls, (b) initial data for pre lling forms, (c)
modi cations to the initial data for computing di s, and (d) the
nal RDF data.
1 &lt;div rex-context
2 rex-prefix="dbr: http://dbpedia.org/resource/"
3 rex-subject="dbr:Chemnitz"&gt;
4 &lt;input type="text"
5 ng-model="cityName"
6 rex-predicate="rdfs:label"
7 rex-object rex-type="literal"
8 rex-value="cityName"&gt;
9 &lt;/div&gt;
Note, that the Talis RDF JSON is used as an intermediate
representation. The nal RDF graph, that corresponds to
the form state, can be serialized in any RDF syntax,
including JSON-LD10.</p>
        <p>For convenience, pre xes can be used to abbreviate IRIs. By
default, all pre xes of the RDFa initial context11 are readily
available. Custom namespaces can be enabled by specifying
rex-prefix, where the argument must follow the same
syntax as in RDFa12. Also, REX features the short hands
rexiri="m" and rex-literal="m", which are expanded to
rextype="`uri'", rex-value="m" and rex-type="`literal'"
and rex-value="m", respectively.</p>
        <p>Whenever multiple attributes occur on the same element,
the order of processing depends on their priority value. For
details please refer to the documentation on Github.
2.2 Accessing the Data and Modifications
The rexContext object is a container for all relevant
information about the state of the form and performed modi
cations. It provides the following attributes:
.base The base RDF graph, in Talis RDF JSON, which
holds information about the resources referenced by
the form controls. This information is automatically
updated accordingly when the set of subject resources
and or lookup functions change.
.override A (partial) Talis RDF JSON object which
holds the state of the data entered into the form and
which can be seen to \override" any base data.
.graph The RDF graph that holds the e ective set of
triples. This is thus obtained by applying the overrides
to the base data for all data referenced by coordinates
of the form.
.di .added and .di .removed RDF graphs13 containing
the triples that were added/removed in regard to the
base data and referenced coordinates.</p>
      </sec>
    </sec>
    <sec id="sec-3">
      <title>8https://docs.angularjs.org/api/ng/service</title>
      <p>/$interpolate
9http://www.w3.org/TR/rdf-json/</p>
      <sec id="sec-3-1">
        <title>Listing 1: A minimal REX example</title>
        <p>Within a rex-context section, the basic annotations are:
rex-subject, rex-predicate, and rex-object. While
rexsubject and rex-predicate accept strings with markup8 for
IRIs as values, rex-object takes an index. The index refers to 1 &lt;pre ng init="rc=rexContext"&gt;
the i th RDF term for a given subject and predicate. Inter- 2 ffgraphToTurtle(rc.graph, rexPre xMapping)gg
nally, the Talis RDF JSON9 model is used for representing 3 ffcreateInsertRequest(rc. di .added, rexPre xMapping)gg
RDF data. Hence, RDF objects comprise four components 4 ffcreateDeleteRequest(rc. di .removed, rexPre xMapping)gg
of type string, that can be accessed using the annotations 5 &lt;/pre&gt;
rex-type, rex-value, rex-lang, and rex-datatype. In
addition, rex-deleted can be used to ag an object at a
certain index { and thus the corresponding triple { as deleted.</p>
        <p>We refer to the combination of a subject IRI, predicate IRI,
object index and component name as a coordinate. A
coordinate uniquely references a primitive value in an RDF graph.</p>
        <p>Listing 2: Example of serializing the current state of the
RDF graph as turtle, and creating SPARQL 1.1 Update
queries from the di
Listing 2 shows how a turtle representation of the current
state of the RDF graph and the SPARQL Insert/Delete
queries based on the di can be rendered in real-time using
AngularJS. The neccessary serialization functions are part
of the REX utility belt.
10http://json-ld.org/
11http://www.w3.org/2011/rdfa-context/rdfa-1.1
12http://www.w3.org/TR/rdfa-syntax/#A-prefix
13http://www.w3.org/TR/rdf-interfaces/
1 &lt;input type="hidden"
2 ng-if="PointUtils.isWktPoint(wkt)"
3 rex-predicate="geo:long"
4 rex-literal="`' + PointUtils.wktToXy(wkt).x"
5 rex-datatype="`xsd:float'"&gt;</p>
        <p>Listing 3: Generating triples only for valid WKT strings</p>
        <sec id="sec-3-1-1">
          <title>2.4 Data Lookups for Prefilling Forms</title>
          <p>Forms can be connected to a SPARQL endpoint using
rexsparql-service="sparqlService" and rex-lookup="true".
Whenever the value of a rex-subject changes and
rexlookup is enabled, a lookup will be performed, and the 1 &lt;ul
data is converted to Talis RDF JSON and stored at rex- 2
Context.json. Listing 4 shows an example set up using a
utility method from the Jassa library.</p>
        </sec>
        <sec id="sec-3-1-2">
          <title>2.3 Conditional RDF generation</title>
          <p>There are cases when RDF output should be constructed 1 &lt;div rex-predicate="dbo:birthDate"
conditionally based on the form and validation state. For 2 rex-literal="bdateStr" rex-datatype="`xsd:date'"&gt;
example, consider a form that allows a user to enter a Well 3 &lt;input type="text" ng-model="bdate"
Known Text (WKT) string, and corresponding WGS84 lat/- 4 sync-source="bdate" sync-target="bdateStr"
long triples should be generated for valid POINT geometries. 5 sync-to-target="dateToString"
One way to accomplish this is using a combination of ng-if 6 sync-to-source="stringToDate"
and hidden elds, as shown in Listing 3. 7 datepicker-popup="dd-MMMM-yyyy"
8 datepicker-options="dateOptions"&gt;
9 &lt;/div&gt;
1 &lt;script type="text/javascript"&gt;
2 $scope.sparqlService = new jassa.service
3 .SparqlServiceHttp(endpointUrl, defaultGraphIri);
4 }
5 &lt;/script&gt;
6 &lt;form
7 rex-context
8 rex-sparql-service="sparqlService"
9 rex-lookup="true"
10 rex-subject="http://dbpdia.org/resource/Leipzig"&gt;
11 &lt;!-- ... further form controls ... --&gt;
12 &lt;/form&gt;</p>
          <p>Listing 4: Registering a lookup function for pre lling out
forms based on subject resources</p>
        </sec>
        <sec id="sec-3-1-3">
          <title>2.5 Synchronization with Conversion</title>
          <p>Sometimes (datatype) conversions are necessary to map
values between their representation in a form control and the
one in the RDF structure. For example, the model of the
date picker of AngularUI Bootstrap14 stores values of type
Date. However, its appropriate (lexical) representation as a
literal of xsd:date is a string conforming to ISO8601. We
solve this problem by introducing a set of sync-*
annotations for synchronizing model values, as shown in
Listing 5. The source and target of a sync are declared using
sync-source, sync-target. With sync-to-target and/or
sync-to-source any changes in the values are propagated
in the respective direction. Both attributes take a
conversion function as an optional argument. If desired, syncing in
one of the directions can be enabled/disabled by specifying
a condition expression using sync-to-target-cond and/or
sync-to-source-cond.
14http://angular-ui.github.io/bootstrap/</p>
        </sec>
      </sec>
      <sec id="sec-3-2">
        <title>Listing 5: Data binding with conversions</title>
        <sec id="sec-3-2-1">
          <title>2.6 Navigation and Filtering</title>
          <p>Especially with nested forms it is necessary to navigate
between sets of related resources. For example, consider an
RDF resource that represents the DBpedia dataset, and
another set of resources that represent distributions in SPARQL
endpoints on the Web. Further, assume that the
distributions refer to the dataset of which they are a distribution
of.</p>
          <p>rex-subject="http://.../dataset/dbpedia"
3 rex-nav-predicate="o:distributionOf"
4 rex-nav-inverse="true"
5 rex-nav-filter-type="iri"
6 rex-nav-values="distIris"&gt;
7 &lt;li
8 ng-repeat="distIri in distIris"
9 rex-subject="{{distIri}}"&gt;
10 &lt;!-- sub-form for each distribution --&gt;
11 &lt;/li&gt;
12 &lt;/ul&gt;</p>
          <p>The variable distIri will be an array containing all
distributions that are reachable from the current subject by
following the predicate o:distributionOf in inverse direction. The
array distIri has special behaviour attached to it: Pushing
items to it will implicitly create new triples that connect the
given subject with the added URI via the given property.</p>
        </sec>
        <sec id="sec-3-2-2">
          <title>2.7 Renaming resources</title>
          <p>While it may seem intriguing to make use of the rex-subject
annotation for the purpose of renaming resources, this is not
directly in the scope of the REX system. REX uses the
concept of coordinates to give model values an RDF context.
Under this perspective, coordinates are only references used
to get and put model values from resp. into an RDF space,
i.e. a component of a triple in an RDF graph. But
coordinates are distinct from operations to be performed on an
RDF graph.</p>
        </sec>
        <sec id="sec-3-2-3">
          <title>3. USE CASES</title>
          <p>In this section we brie y outline two use cases that we
realized with REX and which are part of the online demo.
The rst one is the simple generic resource editor depicted
in Figure 1. When the user con gures a SPARQL endpoint
and enters the URI of a resource to edit, a form is generated
by iterating over the corresponding properties and objects
of the data in rexContext. This data is automatically loaded
using REX's lookup mechanism. For each RDF term, an
instance of our rdf-term-input widget is created. This widget is
realized as an AngularJS directive whose model represents
an RDF term using the attributes de ned by Talis RDF
JSON. We also created a geometry-input widget that can
two-way data bind on models with WKT strings. Another
use case is a simple form for registering datasets together
with information about which SPARQL endpoints they are
distributed in.</p>
        </sec>
        <sec id="sec-3-2-4">
          <title>4. RELATED WORK</title>
          <p>
            There exist several tools for matching, transforming and
templating RDF data for visual presentation: Fresnel [
            <xref ref-type="bibr" rid="ref3">3</xref>
            ] was
one of the rst approaches in this regard. Sgvizler [
            <xref ref-type="bibr" rid="ref4">4</xref>
            ] is
a library that enables one to use SPARQL queries as
attribute values in HTML elements and bind their result sets
to di erent types of visualizations. Recent approaches in
this category are the AngularJS-based RDF Stylesheet
Language Transformations [
            <xref ref-type="bibr" rid="ref2">2</xref>
            ] and Uduvudu15.
          </p>
          <p>
            A di erent approach is taken by frameworks that feature
RDF widgets: SemWidg [
            <xref ref-type="bibr" rid="ref6">6</xref>
            ] is a JavaScript based library
that provides a framework and tooling for creating
widgets, a widget library and a path query language called
SemwidgQL. Vie.js is a JavaScript library for building
decoupled Content Management Systems, and implements a
bridge between Backbone.js and Semantic Web data. Vie
also features a form generation component16. RDFauthor 17
is a JavaScript library that adds a feature-rich authoring
component to either a speci ed region of a Web page or its
own window-like overlay.
          </p>
          <p>
            Semantic Web platforms, such as OntoWiki [
            <xref ref-type="bibr" rid="ref1">1</xref>
            ], PoolParty18
and VocBench 19 o er features for many aspects of RDF
data management, as for example data aquisition, analysis
and publishing.
5. CONCLUSIONS &amp; FUTURE WORK
In this demo paper, we presented the REX system for
creating highly dynamic HTML forms for RDF data based on the
AngularJS framework. We showed how the system is used to
realize a number of use cases, such as pre lling form elds,
conditionally emitting data, converting values between the
elds and the RDF graph, and creating SPARQL 1.1 Update
requests for persisting changes. We showed how our
system enables idiomatic re-use of existing widgets, such as the
date picker of AngularUI Bootstrap, and our own widgets
for editing RDF terms and geometries. Further,
investigating the use of REX for form generation approaches, which
could arrange prede ned HTML building blocks to create
appropriate forms for RDF resources seems worthwhile.
Finally, there are several possibilities of combining this work
with other e orts, such as the RDF Changeset systems or
access control approaches in general.
          </p>
        </sec>
        <sec id="sec-3-2-5">
          <title>Acknowledgment</title>
          <p>This work was supported by grants from the EU's 7th
Framework Programme provided for the GeoKnow project (GA no.
318159).</p>
        </sec>
      </sec>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>P.</given-names>
            <surname>Frischmuth</surname>
          </string-name>
          et al.
          <article-title>OntoWiki|An Authoring, Publication and Visualization Interface for the Data Web</article-title>
          .
          <source>Semantic Web Journal</source>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>S.</given-names>
            <surname>Peroni</surname>
          </string-name>
          and
          <string-name>
            <given-names>F.</given-names>
            <surname>Vitali</surname>
          </string-name>
          . Rslt:
          <article-title>Rdf stylesheet language transformations</article-title>
          .
          <source>In Proceedings of the ESWC Developers Workshop</source>
          <year>2015</year>
          , CEUR Workshop Proceedings,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>E.</given-names>
            <surname>Pietriga</surname>
          </string-name>
          ,
          <string-name>
            <given-names>C.</given-names>
            <surname>Bizer</surname>
          </string-name>
          ,
          <string-name>
            <given-names>D.</given-names>
            <surname>Karger</surname>
          </string-name>
          , and
          <string-name>
            <given-names>R.</given-names>
            <surname>Lee</surname>
          </string-name>
          .
          <article-title>Fresnel: A browser-independent presentation vocabulary for rdf</article-title>
          .
          <source>In The semantic web-ISWC</source>
          <year>2006</year>
          , pages
          <fpage>158</fpage>
          {
          <fpage>171</fpage>
          .
          <year>2006</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <surname>M. G.</surname>
          </string-name>
          <article-title>Skj veland. Sgvizler: A javascript wrapper for easy visualization of sparql result sets</article-title>
          .
          <source>In ESWC (Satellite Events)</source>
          , volume
          <volume>7540</volume>
          of Lecture Notes in Computer Science, pages
          <volume>361</volume>
          {
          <fpage>365</fpage>
          . Springer,
          <year>2012</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>C.</given-names>
            <surname>Stadler</surname>
          </string-name>
          ,
          <string-name>
            <given-names>P.</given-names>
            <surname>Westphal</surname>
          </string-name>
          , and
          <string-name>
            <given-names>J.</given-names>
            <surname>Lehmann</surname>
          </string-name>
          .
          <article-title>Jassa - A javascript suite for sparql-based faceted search</article-title>
          .
          <source>In Proc. ISWC Developers Workshop 2014</source>
          , pages
          <fpage>31</fpage>
          {
          <fpage>36</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>T.</given-names>
            <surname>Stegemann</surname>
          </string-name>
          and
          <string-name>
            <given-names>J.</given-names>
            <surname>Ziegler</surname>
          </string-name>
          .
          <article-title>Semwidgjs: A semantic widget library for the rapid development of user interfaces for linked open data</article-title>
          .
          <source>In 44. Jahrestagung der Gesellschaft fur Informatik</source>
          ,
          <source>Informatik</source>
          <year>2014</year>
          , Big Data - Komplexitat meistern,
          <volume>22</volume>
          .-
          <fpage>26</fpage>
          .
          <article-title>September 2014 in Stuttgart</article-title>
          , Deutschland, pages
          <volume>479</volume>
          {
          <fpage>490</fpage>
          ,
          <year>2014</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>