Templating the Semantic Web via RSLT
- 1.1k Downloads
In this paper we introduce RSLT, a simple transformation language for RDF data. RSLT organises the rendering of RDF statements as transformation templates associated to properties or resource types and producing HTML. A prototype based on AngularJs is presented and we also discuss some implementation details and examples.
KeywordsRDF dataset visualisation RSLT Templates
Works introducing methods and tools for creating visual representations of RDF data exist, e.g., [2, 3, 5, 6, 7], and of course some visualisation interfaces are supported in existing triplestores such as Virtuoso1. Nonetheless, visualisation tools for RDF data are still far less sophisticated than reporting tools for other data types, e.g., for traditional databases. For instance, most of such tools display triplestore content as simple tabular data, provide little or no way to prioritise differently identificative, descriptive and secondary properties, or even to customise or reorganise the order in which properties are displayed; often, related entities are presented as an opaque IRI rather than some textual description of the nature and feature of the entity, so that readability is basically absent.
the tool should be easy to integrate in a web-based application;
it should be possible (even to non-Semantic Web people, e.g., practitioners of traditional web-based technologies such as HTML and XML) to represent convoluted OWL entities more or less as easily as individual RDF statements;
related entities should be meant to be represented with readable and meaningful text or other representations rather than as the IRI they are represented by – but their IRI should still be available for special rendering needs (e.g., as destinations for links and HTML anchors);
complex representations of main resources should be built by composition, i.e. by combining simple representations of lesser entities and properties.
Traditional reporting software tools have limitations, such as the complexity to integrate them in web-based architectures or the variety and complexity of approaches in generating and delivering the reports. Yet, we found XSLT  a fairly natural and sophisticated approach to provide presentation support to XML documents, and sought to provide something similar for RDF data.
In this paper we introduce RSLT (RDF Stylesheet Language Transformations, pronounced result), a simple transformation language for RDF data. RSLT organises rendering as transformation templates associated to resources, properties or resource types, produces HTML and can recursively call other templates. A browser-based prototype based on the AngularJs library has been created that allows client-based presentations of SPARQL constructs, and soon of Turtle datasets as well. The rest of the paper is organised as follows: in Sect. 2 we introduce the main constructs of RSLT. In Sect. 3 we introduce some implementation details of RSLT and few examples, and in Sect. 4 we conclude the paper by sketching out some future works.
RDF Stylesheet Language Transformations (RSLT)2, pronounced result, is a direct and trivial translation of (some parts of) the XSLT language into the RDF domain. Similarly to its noble ancestor, an RSLT document contains a number of templates that create fragments of output in some displayable format (e.g., HTML) when navigating through a graph of RDF statements. The fact that RDF graphs, differently than XML documents, lack a natural hierarchy in its internal organisation and that no obvious selector language for RDF exists3 provide for some interesting complications of the original design, though.
The above template will be fired at the beginning of the process and will create an HTML div element, and will first select all entities whose foaf:familyNa me is “Horrocks”, and then look for a reasonable template for each of them.
Whenever the rendering engine comes across an entity of type foaf:Person, this template is triggered, creating an HTML fragment with a Open image in new window element containing text and the values of data properties foaf:givenName and foaf:family Name, then an Open image in new window element containing the rendering recursively produced by selecting all entities ??work related to ?person through the chain of properties pro:holdsRoleInTime / pro:relatedToDocument. This rendering is generated by looking for and executing the templates that match the ??work entities just selected. In order to avoid circularity in the selection of templates, a simple approach is taken to consider the template as spent when applied in a recursion, so it cannot be chosen and applied again inside itself. Once all relevant templates have been spent, if a template for a specific entity is needed again, a default one is applied that does not recurse, thus halting any potential circularity.
In addition to Open image in new window and Open image in new window , at the moment the RSLT language inherits from XSLT also constructs such as Open image in new window and Open image in new window that have similar behaviour as their XSLT counterparts. Also, the template element inherits the mode and priority attributes, with similar functions to XSLT. Finally, the Open image in new window element allows the specification of a triple store through the triplestore attribute, and element Open image in new window allows the specification of prefixes for selectors and property names.
In conclusion, RSLT is rather similar to its ancestor, XSLT, but for a few key differences, such as the specification of a different selector language, and the efficiency requirement that led us to include the preload attribute. The selector language is in itself just a subset of the SPARQL language, similarly to how the selector language XPath is but a subset of the query language XQuery, and for similar reasons. Would it be possible to just use an existing implementation of XSLT? Unfortunately, the requirements for non-circularity in template matching and the effort to adapt a new selector language to existing code probably makes this endeavour excessive and not worthy. We have rather reimplemented a few key commands of the language relying on a few peculiarities of AngularJs directives, as explained in the next section.
3 An Implementation of RSLT
The ng-app attribute of element Open image in new window is required by AngularJs to create an Angular application (named ’simplestRSLT’), which corresponds to an empty AngularJs module that simply includes and uses the RSLT library. Anywhere in the body of the HTML document the Open image in new window element creates the rendering of the entities selected in its $start template.
At the address http://www.fabiovitali.it/rslt/ it is possible to find four working examples of RSLT, all using as data source the Semantic Lancet Triplestore . The first and the second examples are identical and show the simplest RSLT document accessing and rendering entities and properties across seven different classes – the only difference being in the rendering speed (which in example 1 is lacks any preload instruction in the queries).
The third example is a simple and straightforward reimplementation of the Lancet Data Browser (http://www.semanticlancet.eu/browser) already presented in , whose source code becomes incredibly simpler and more straightforward through the use of the RSLT library. Finally, example 4 (see Fig. 1) is a tool for the RSLT programmer that supports the interactive specifications of triplestores, start-with RSLT entities, pre-loaded RSLT entities, and templates (both in XML as described in this paper as well as in an experimental JSON format not yet documented) as well as checks the output of the RSLT transformation, the actual SPARQL queries sent to the triplestore and the list of entities that have been downloaded client-side by the full sequence of SPARQL queries generated through the execution of the RSLT templates.
In this paper we have introduced RSLT, i.e., a simple transformation language for RDF data. RSLT organises rendering of RDF statements in a triplestore through transformation templates recursively producing HTML. A prototype based on the AngularJs library has been presented. In the future, there are ongoing plans to integrate support for the management of Turtle and JSON-LD files, to extend the language to supporting more features of the XSLT language and of the query language. Finally, our plan is to study the requirements for providing support of the language on the server as well.
RSLT is available on GitHub: https://github.com/fvitali/rslt. The tool as well as all the additional scripts are distributed under an ISC License, while the other related files such as HTML documents are distributed under a CC-BY 4.0 License.
SPARQL cannot be considered as a pure selector language for RDF as XPath, used by XSLT, is. Rather, it is a full-featured query language, similar to XQuery for XML.
- 1.Bagnacani, A., Ciancarini, P., Di Iorio, A., Nuzzolese, A.G., Peroni, S., Vitali, F.: The semantic Lancet project: a linked open dataset for scholarly publishing. In: Lambrix, P., Hyvönen, E., Blomqvist, E., Presutti, V., Qi, G., Sattler, U., Ding, Y., Ghidini, C. (eds.) EKWA 2014 Satellite Events. LNCS, vol. 8982, pp. 101–105. Springer, Heidelberg (2015) Google Scholar
- 3.Corby, O., Faron-Zucker, C., Gandon, F.: SPARQL template: a transformation language for RDF (2014). https://hal.inria.fr/hal-00969068v1
- 4.Kay, M.: XSL Transformations (XSLT) Version 2.0. W3C Recommendation, 23 January 2007. World Wide Web Consortium (2007). http://www.w3.org/TR/xslt20/
- 5.Luggen, M., Gschwend, A., Bernhard, A., Cudré-Mauroux, P.: Uduvudu: a graph-aware and adaptive UI engine for linked data. In: Proceedings of LDOW 2015 (2015)Google Scholar
- 6.Pietriga, E., Bizer, C., Karger, D.R., Lee, R.: Fresnel: a browser-independent presentation vocabulary for RDF. In: Cruz, I., Decker, S., Allemang, D., Preist, C., Schwabe, D., Mika, P., Uschold, M., Aroyo, L.M. (eds.) ISWC 2006. LNCS, vol. 4273, pp. 158–171. Springer, Heidelberg (2006) CrossRefGoogle Scholar
Open Access This chapter is licensed under the terms of the Creative Commons Attribution-NonCommercial 2.5 International License (http://creativecommons.org/licenses/by-nc/2.5/), which permits any noncommercial use, sharing, adaptation, distribution and reproduction in any medium or format, as long as you give appropriate credit to the original author(s) and the source, provide a link to the Creative Commons license and indicate if changes were made.
The images or other third party material in this chapter are included in the chapter's Creative Commons license, unless indicated otherwise in a credit line to the material. If material is not included in the chapter's Creative Commons license and your intended use is not permitted by statutory regulation or exceeds the permitted use, you will need to obtain permission directly from the copyright holder.