STTL SPARQL Template Transformation Language for RDF Graphs

Similar documents
STTL: A SPARQL-based Transformation Language for RDF

Validating Ontologies against OWL 2 Profiles with the SPARQL Template Transformation Language

A Transformation Language for RDF based on SPARQL

SPARQL Template: A Transformation Language for RDF

SADI Semantic Web Services

The P2 Registry

XSLT (part II) Mario Alviano A.Y. 2017/2018. University of Calabria, Italy 1 / 19

LDScript : a Linked Data Script Language

Day 2. RISIS Linked Data Course

Building Blocks of Linked Data

Publishing OWL ontologies with Presto

XSLT: How Do We Use It?

Semantic Web Technologies: Assignment 1. Axel Polleres Siemens AG Österreich

Filter: Evaluable Expression. List Syntax. Tests. Filter: Evaluable Expression. Tests : functions. Tests 06/09/2013. (1?x v )

XML. Objectives. Duration. Audience. Pre-Requisites

Comparison of Semantic Web serialization syntaxes

Semantic Web. Lecture 12: SW Programming Dr. Knarig Arabshian

Extensions to XSLT 1.0, and XSLT 2.0

ISWC 2017 Tutorial: Semantic Data Management in Practice

Representing Linked Data as Virtual File Systems

Chapter 3 Querying RDF stores with SPARQL

Nested Queries in SPARQL

SEMANTIC WEB 07 SPARQL TUTORIAL BY EXAMPLE: DBPEDIA IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD

Introduction to a Web of Linked Data

Semantic Web Fundamentals

Computer Science E-259

LDScript: a Linked Data Script Language

Advanced XSLT editing: Content query web part (CQWP) Dolev Raz SharePoint top soft Soft.co.il

SPARQL By Example: The Cheat Sheet

XSLT. Announcements (October 24) XSLT. CPS 116 Introduction to Database Systems. Homework #3 due next Tuesday Project milestone #2 due November 9

Interacting with Linked Data Part I: General Introduction

Fuseki Server Installation

Tony Mallia Edmond Scientific

Combining RDF Vocabularies for Expert Finding

Semantic Web. MPRI : Web Data Management. Antoine Amarilli Friday, January 11th 1/29

Semantic Web Information Management

Querying Semantic Web Data

Querying the Semantic Web

XSLT program. XSLT elements. XSLT example. An XSLT program is an XML document containing

SPARQL. Dr Nicholas Gibbins

From the Web to the Semantic Web: RDF and RDF Schema

SPARQL QUERY LANGUAGE WEB:

XSL Elements. xsl:copy-of

Semantic Integration with Apache Jena and Apache Stanbol

Semantic Web and Python Concepts to Application development

Formalising the Semantic Web. (These slides have been written by Axel Polleres, WU Vienna)

Today s Plan. INF3580 Semantic Technologies Spring Outline. Oblig 4. Lecture 13: More SPARQL. Kjetil Kjernsmo.

COMPUTER AND INFORMATION SCIENCE JENA DB. Group Abhishek Kumar Harshvardhan Singh Abhisek Mohanty Suhas Tumkur Chandrashekhara

Comp 336/436 - Markup Languages. Fall Semester Week 9. Dr Nick Hayward

RDF AND SPARQL. Part IV: Syntax of SPARQL. Dresden, August Sebastian Rudolph ICCL Summer School

Linked Data Evolving the Web into a Global Data Space

Semantic Web Fundamentals

Wonghong Jang LG Sangnam Digital Library Manager

XSL Transformation (XSLT) XSLT Processors. Example XSLT Stylesheet. Calling XSLT Processor. XSLT Structure

ISA Action 1.17: A Reusable INSPIRE Reference Platform (ARE3NA)

SPARQL UniProt.RDF. Everyone has had some introduction slash knowledge of RDF.

Paper for Consideration by the S-100 Working Group. S-100 Portrayal Support for Lua

Linked Data. Department of Software Enginnering Faculty of Information Technology Czech Technical University in Prague Ivo Lašek, 2011

A Deductive System for Annotated RDFS

Generating Variants Using XSLT Tutorial

On the Semantics of Heterogeneous Querying of Relational, XML and RDF Data with XSPARQL

COPYRIGHTED MATERIAL. Contents. Part I: Introduction 1. Chapter 1: What Is XML? 3. Chapter 2: Well-Formed XML 23. Acknowledgments

University of Rome Tor Vergata DBpedia Manuel Fiorelli

XML. Marie Dubremetz Uppsala, April 2014

Linked Data Semantic Web Technologies 1 (2010/2011)

Package rrdf. R topics documented: February 15, Type Package

Exam : Title : XML 1.1 and Related Technologies. Version : DEMO

2. Knowledge Representation Applied Artificial Intelligence

Linked Data: What Now? Maine Library Association 2017

SPARQL ME-E4300 Semantic Web,

Introducing Linked Data

Linked Data and RDF. COMP60421 Sean Bechhofer

Extracting Ontologies from Standards: Experiences and Issues

An Introduction to the Semantic Web. Jeff Heflin Lehigh University

INF3580 SPRING 2014 EXERCISES WEEK 4

BUILDING THE SEMANTIC WEB

OWL Tutorial. LD4P RareMat / ARTFrame Meeting Columbia University January 11-12, 2018

Semantic Web Systems Querying Jacques Fleuriot School of Informatics

Modern Trends in Semantic Web

Lars Schmidt-Thieme, Information Systems and Machine Learning Lab (ISMLL), University of Hildesheim, Germany, Course on XML and Semantic Web

Profiles Research Networking Software API Guide

Programming Technologies for Web Resource Mining

XSLT Programming Constructs

Author: Irena Holubová Lecturer: Martin Svoboda

XPath and XSLT. Overview. Context. Context The Basics of XPath. XPath and XSLT. Nodes Axes Expressions. Stylesheet templates Transformations

COMP9321 Web Application Engineering

COMP9321 Web Application Engineering

White Paper. XML-Based Export and Import of Objects Using XSLT. Fabasoft Folio 2017 R1 Update Rollup 1

Semi-structured Data 11 - XSLT

Jena.

SPAR-QL. Mario Arrigoni Neri

RESOURCES DESCRIPTION FRAMEWORK: RDF

EXAM XML 1.1 and Related Technologies TYPE: DEMO

Abstract. The report is written in english. Keywords: Linked Data, Clinical Data, Semantic Web, AstraZeneca, RDF, OWL, SPARQL, Jena

Extensible Markup Stylesheet Transformation (XSLT)

SEMANTIC WEB 03 RDF DATA MODEL RESOURCE DESCRIPTION FRAMEWORK IMRAN IHSAN ASSISTANT PROFESSOR, AIR UNIVERSITY, ISLAMABAD

Linked data and its role in the semantic web. Dave Reynolds, Epimorphics

in a corporate semantic web

info-h-509 xml technologies Lecture 5: XSLT Stijn Vansummeren February 14, 2017

XML and Semantic Web Technologies. II. XML / 5. XML Stylesheet Language Transformations (XSLT)

Transcription:

STTL SPARQL Template Transformation Language for RDF Graphs Olivier Corby INRIA Sophia Antipolis olivier.corby@inria.fr

STTL STTL : transformation language for RDF XSLT : transformation language for XML Input RDF graph Output Text format SPARQL based Declarative transformation rules SPARQL Template Transformation Language 2

XSLT - STTL <xsl:template match="person"> <xsl:apply-templates select="knows"/> </xsl:template> template { st:apply-templates(?y) } where {?in a foaf:person ; foaf:knows?y } SPARQL Template Transformation Language 3

XSLT - STTL XSLT STTL Input XML RDF Output XML Text Syntax XML SPARQL extension Template xsl:template template where Named template xsl:template name="test" template ex:test Apply templates xsl:apply-templates st:apply-templates Apply named template xsl:call-template st:call-template Parameters xsl:with-param (?x,?y) Numbering xsl:number st:number Sorting xsl:sort order by Grouping xsl:for-each-group group by Condition xsl:if if (exp, then, else) SPARQL Template Transformation Language

Differences XSLT - STTL XSLT : XML Tree Edges are ordered STTL : RDF Graph Edges are not ordered SPARQL Template Transformation Language 5

STTL motivating use cases 1. Transformation of RDF data from one RDF syntax to another: Turtle RDF/XML JSON LD 2. Presentation of RDF data: RDF to HTML RDF to Latex RDF to Natural Language RDF to graphic format (GML) 3. Transformation of statements in a given language from RDF to another syntax: OWL/RDF to OWL functional syntax SPARQL/RDF (SPIN) to SPARQL syntax AST of L in RDF to concrete syntax of L 4. Constraint checking OWL Profile: OWL RL SHACL SPARQL Template Transformation Language 6

Example use case: OWL/RDF to OWL/FS a:parent owl:equivalentclass [ a owl:restriction ; owl:onproperty a:haschild; owl:somevaluesfrom a:person] OWL/RDF (Turtle) owl:restriction rdf:type a:parent owl:equivalentclass STTL transformation owl:onproperty a:haschild owl:somevaluesfrom a:person EquivalentClasses (a:parent ObjectSomeValuesFrom(a:hasChild, a:person) ) OWL/Functional Syntax SPARQL Template Transformation Language 7

SPARQL Query forms 1. SELECT WHERE { GP } 2. CONSTRUCT { GP } WHERE { GP } 3. ASK { GP } 4. DESCRIBE WHERE { GP } SPARQL Template Transformation Language 8

SPARQL Template Query forms 1. SELECT WHERE { GP } 2. CONSTRUCT { GP } WHERE { GP } 3. ASK { GP } 4. DESCRIBE WHERE { GP } 5. TEMPLATE { Text Pattern } WHERE { GP } SPARQL Template Transformation Language 9

SPARQL Template An additional SPARQL query form: TEMPLATE { Text Pattern } WHERE { GP } with Text Pattern = ( VARIABLE EXP TEXT )* SPARQL Template Transformation Language 10

RDF to Turtle transformation TEMPLATE {?x " " rdfs:label " "?name "." } WHERE {?x a foaf:person ; foaf:name?name } ns:olivier a foaf:person ; foaf:name "Olivier". ns:catherine a foaf:person ; foaf:name "Catherine". ns:olivier rdfs:label "Olivier". ns:catherine rdfs:label "Catherine". SPARQL Template Transformation Language 11

RDF to HTML transformation TEMPLATE { format {"<a href='%s'>%s</a>" str(?x) str(?name) } } WHERE {?x a foaf:person ; foaf:name?name } ns:olivier a foaf:person ; foaf:name "Olivier". ns:catherine a foaf:person ; foaf:name "Catherine". <a href='http://ns.inria.fr/olivier'>olivier</a> <a href='http://ns.inria.fr/catherine'>catherine</a> SPARQL Template Transformation Language 12

STTL: Transformation A set of templates TEMPLATE { "EquivalentClasses ("?in " "?c ")" } WHERE {?in owl:equivalentclass?c } TEMPLATE { "SubClassOf ("?in " "?c ")" } WHERE {?in rdfs:subclassof?c } TEMPLATE { "ObjectSomeValuesFrom ("?p " "?c ")" } WHERE {?in a owl:restriction ; owl:onproperty?p ; owl:somevaluesfrom?c } SPARQL Template Transformation Language 13

Template recursive call TEMPLATE { "EquivalentClasses ("?in " "?c ")" } WHERE {?in owl:equivalentclass?c. } SPARQL Template Transformation Language 14

Template recursive call TEMPLATE { "EquivalentClasses (" st:apply-templates(?in) " "?c ")" } WHERE {?in owl:equivalentclass?c. } SPARQL Template Transformation Language 15

Template recursive call TEMPLATE { "EquivalentClasses (" st:apply-templates(?in) " " st:apply-templates(?c) ")" } WHERE {?in owl:equivalentclass?c. } SPARQL Template Transformation Language 16

STTL 1. Template: SPARQL Template Query form 2. Transformation: set of templates 3. Extension function: st:apply-templates, st:call-template SPARQL Template Transformation Language 17

Focus Node template { st:apply-templates(?y) } where {?in foaf:knows?y } SPARQL Template Transformation Language 18

Focus Node template { st:apply-templates(?y) } where {?in foaf:knows?y } template {} where {?in a foaf:person } SPARQL Template Transformation Language 19

Named Template template { st:call-template(st:title) } where {} SPARQL Template Transformation Language 20

Named Template template { st:call-template(st:title) } where {} template st:title {} where {} SPARQL Template Transformation Language 21

Named Template template { st:call-template(st:title,?y) } where {} template st:title (?x) {} where {} SPARQL Template Transformation Language 22

STTL Features SPARQL Template Transformation Language 23

STTL Extension Functions prefix st: <http://ns.inria.fr/sparql-template/> st:apply-templates(term) st:apply-templates-with(transform-uri, term) st:call-template(template-uri, term) st:call-template-with(transform-uri, template-uri, term) st:turtle(term) SPARQL Template Transformation Language 24

Priority template { } where { } pragma { st:template st:priority 200 } SPARQL Template Transformation Language 25

Start template template st:start { st:apply-templates(?x) } where {?x a foaf:person } SPARQL Template Transformation Language 26

Extension Functions function us:display(?x) { if (isblank(?x), concat("bnode: ",?x), st:turtle(?x)) } SPARQL Template Transformation Language 27

Profile: Define Extension Functions template st:profile {} where {} function us:display(?x) { if (isblank(?x), concat("bnode: ",?x), st:turtle(?x)) } SPARQL Template Transformation Language 28

Variable Processing template {?y } where {?in?p?y } template { st:process(?y) } where {?in?p?y } function st:process(?x) { st:turtle(?x) } SPARQL Template Transformation Language 29

Overloading Variable Processing function st:process(?x) { if (isblank(?x), st:apply-templates(?x), st:turtle(?x)) } SPARQL Template Transformation Language 30

Template Statements Separator Format Group Box Numbering SPARQL Template Transformation Language 31

Separator template {?y ; separator = ", " } where {?in foaf:knows?y } SPARQL Template Transformation Language 32

Format template { format { "<h2>%1$s</h2><p>%2$s</p>" st:apply-templates(?x) st:apply-templates(?y) } } where { } SPARQL Template Transformation Language 33

External Format template { format { <http://example.org/format/test.html> st:apply-templates(?x) st:apply-templates(?y) } } where { } SPARQL Template Transformation Language 34

Format Function st:format(format, exp+) SPARQL Template Transformation Language 35

Group group { E1.. En } ::= group_concat(concat(e1,.. En)) SPARQL Template Transformation Language 36

Group template {?in " : " group {?y } } where {?in foaf:knows?y } SPARQL Template Transformation Language 37

Box box { E1.. En } ::= concat(e1,.. En) st:nl() box sbox ibox SPARQL Template Transformation Language 38

Box box: nl(+1) exp nl(-1) sbox: nl(+1) exp indent(-1) ibox: indent(+1) exp indent(-1) SPARQL Template Transformation Language 39

Numbering template { st:number() " " st:apply-templates(?x) } where {?in foaf:knows?y } order by?x SPARQL Template Transformation Language 40

Compiling STTL template { E1.. En } where {} compiled as : select (concat(cp(e1),.. cp(en)) as?out) where {} + aggregate(ω, group_concat,?out) SPARQL Template Transformation Language 41

Compiling STTL cp(var(x)) = st:process(x) Default: st:process(?x) = st:turtle(?x) Overloaded: function st:process(?x) { st:apply-templates(?x) } SPARQL Template Transformation Language 42

STTL Transformations 1. RDF to Turtle st:turtle 2. RDF to RDF/XML st:rdfxml 3. RDF to JSON-LD st:jsonld 4. OWL to Functional Syntax st:owl 5. SPIN to SPARQL st:spin 6. SPARQL Query Result st:sparql 7. SPARQL Tutorial st:web 8. DBpedia Navigator st:navlab 9. Wikipedia Edit History Navigator st:dbedit 10. Calendar st:calendar 11. History Timeline 12. Sudoku (1 template) 13. OWL Profile check st:owlrl 14. SHACL Validation st:dsmain SPARQL Template Transformation Language 43

Usage Create a directory e.g. sttl Write templates in separate files, with extension.rq Use: st:apply-templates-with("/home/myself/sttl/") Use in Java: Transformer t = Transformer.create(g, "/home/myself/sttl/"); String str = t.transform(); SPARQL Template Transformation Language 44

STTL development environment SPARQL Template Transformation Language 45

STTL engine available in the Corese Semantic Web Factory Free download: http://wimmics.inria.fr/corese SPARQL engine STTL engine Standalone environment to develop transformation SPARQL endpoint STTL server Web Server: http://corese.inria.fr SPARQL Template Transformation Language 46

STTL Server Corese Server HTTP Text in output format SPARQL Query STTL Service Query Text in output format SPARQL Engine STTL Engine STTL transformation Local RDF Dataset Remote RDF Dataset SPARQL Template Transformation Language 47

SPARQL Template Transformation Language 48

SPARQL Template Transformation Language 49

SPARQL Template Transformation Language 50

SPARQL Template Transformation Language 51

SPARQL Template Transformation Language 52

SPARQL Template Transformation Language 53

SPARQL Template Transformation Language 54

Conclusion STTL Transformation Language for RDF Based on SPARQL XSLT like SPARQL Template Transformation Language 55

Exercise https://eswc2018-sparql-ext.github.io/tutorial/ Download corese-server-4.0.2.jar Download eswc.tar.gz Extract the archive -> eswc Move corese-server-4.0.2.jar in directory that contains eswc java "-Dfile.encoding=UTF-8" -jar corese-server-4.0.2.jar -lh -debug -pp eswc/profile.ttl URL: http://localhost:8080 Select Demo/Demo (top right) SPARQL Template Transformation Language 56

Exercise eswc archive content: profile.ttl specifies the demo service sttl contains the STTL transformation sttl/format contains HTML formats sttl/query contains SPARQL queries SPARQL Template Transformation Language 57

Exercise Load RDF data produced by SPARQL Generate Generate HTML format using STTL Display sensor locations on a map Display sensor values in a table Compute aggregates: min, max, avg, etc. SPARQL Template Transformation Language 58

<https://ci.mines-stetienne.fr/aqi/data/point?loc=44.150528,-77.3955> a sosa:featureofinterest, geo:point ; rdfs:label "Belleville, Ontario" ; rdfs:seealso <http://aqicn.org/city/canada/ontario/belleville/> ; geo:lat 44.150528 ; geo:long -77.3955. <https://ci.mines-stetienne.fr/aqi/station/1/observations/1527156000#no2> a sosa:observation ; sosa:hasfeatureofinterest <https://ci.mines-stetienne.fr/aqi/data/point?loc=44.150528,-77.3955> ; sosa:hassimpleresult "3.8 ug.m-3"^^cdt:ucum ; sosa:observedproperty <https://ci.mines-stetienne.fr/aqi/data/point?loc=44.150528,-77.3955#no2>; sosa:resulttime "2018-05-24T10:00:00-05:00"^^xsd:dateTime. <https://ci.mines-stetienne.fr/aqi/data/point?loc=44.150528,-77.3955#no2> a aqio:nitrogendioxideproperty ; ssn:ispropertyof <https://ci.mines-stetienne.fr/aqi/data/point?loc=44.150528,-77.3955>. SPARQL Template Transformation Language 59

SPARQL Template Transformation Language 60