Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.
XSLT+SPARQL: Scripting the
  Semantic Web with SPARQL
embedded into XSLT stylesheets
   Diego Berrueta, Jose E. Labra and ...
Outline

1. Introduction
2. Description of XSLT+SPARQL
3. Implementation and examples
4. Conclusions


                   ...
The problem

Many applications need to transform
RDF into markup (e.g. XHTML)
In the XML world, we have XSLT (XML
transfor...
Why I cannot use XSLT?
RDF/XML is complex, messy,
cumbersome ⇒ non-standard XML
serializations are required
XPath expressi...
RDF is not XML, therefore...
RDF is not XML, therefore...
  I will not use XSLT to transform RDF/XML
  I will not use XSLT to transform RDF/XML
  I wil...
RDF is not XML, therefore...
  I will not use XSLT to transform RDF/XML
  I will not use XSLT to transform RDF/XML
  I wil...
Related work
TriX, RDFXSLT: “alternative” RDF
syntaxes in XML
RDF Twig, TreeHugger: add intelligence
to XSLT processors
To...
Scripting RDF transformations

   Many scripting languages have RDF
   APIs, but they’re not standard
   Coding transforma...
XSLT+SPARQL
Two sets of XPath functions to query
RDF models using SPARQL
Intended to be used in @select
expressions of XSL...
Query results XML syntax
<results>
   <result>
     <binding   name=quot;fnamequot;><value>Tom</value>/binding>
     <bind...
Basic functions
sparql:sparql(query [, documentUrl, ...])
sparql:sparqlEndpoint(query, endpointUrl)



Execute SPARQL quer...
Advanced functions (I)
Retrieving and parsing RDF data is
expensive
Advanced functions designed for:
‣   Efficently query ...
Advanced functions (II)
sparql’:parseString(string, syntax)



Creates a model by parsing a string
containg serialized RDF...
Advanced functions (III)
sparql’:readModel(documentUrl, syntax)
sparql’:readModel(nodeset)

Create models by parsing:
1. A...
Advanced functions (IV)
sparql’:mergeModels(model1, model2, ...)



Combines two or more RDF models into a
new one




   ...
Advanced functions (V)
sparql’:sparqlModel(query, model)



Executes a SPARQL query against an
in-memory model




       ...
Two implementations
1. Java-based extension to Apache Xalan
   using Jena
     Exploits the extensibility of XSLT
2. Pure ...
Applications of XSLT+SPARQL
   Transform RDF data for presentation in
   XHTML, SVG...
   Generate reports beyond SPARQL
 ...
Example: Ivan’s acquittances
  <xsl:template match=quot;/quot;>
    <xsl:apply-templates
      select=quot;sparql:sparql(c...
Advanced examples

Querying DBPedia endpoint
HTML displays of SKOS thesauri
  Alphabetic display
  Systematic display (tre...
Conclusions and future work

  XSLT+SPARQL overcomes the
  limitations of XSLT to process RDF
  XSLT+SPARQL can be used to...
Thank you for your
    attention
 diego.berrueta@fundacionctic.org
Upcoming SlideShare
Loading in …5
×

XSLT+SPARQL: Scripting the Semantic Web with SPARQL embedded into XSLT stylesheets

3,130 views

Published on

Slides presented in the SFSW2008 workshop at Tenerife (co-located with ESWC2008). 02 Jun 2008.

Published in: Business, Technology

XSLT+SPARQL: Scripting the Semantic Web with SPARQL embedded into XSLT stylesheets

  1. 1. XSLT+SPARQL: Scripting the Semantic Web with SPARQL embedded into XSLT stylesheets Diego Berrueta, Jose E. Labra and Ivan Herman CTIC Foundation / Universidad de Oviedo / CWI Scripting for the Semantic Web (SFSW’08) Tenerife, 02/Jun/2008
  2. 2. Outline 1. Introduction 2. Description of XSLT+SPARQL 3. Implementation and examples 4. Conclusions 2
  3. 3. The problem Many applications need to transform RDF into markup (e.g. XHTML) In the XML world, we have XSLT (XML transformations) ... what do we have in the RDF world? 3
  4. 4. Why I cannot use XSLT? RDF/XML is complex, messy, cumbersome ⇒ non-standard XML serializations are required XPath expressions (and patterns) are designed for trees, not graphs XSLT is designed for a different data model 4
  5. 5. RDF is not XML, therefore...
  6. 6. RDF is not XML, therefore... I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML
  7. 7. RDF is not XML, therefore... I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML I will not use XSLT to transform RDF/XML
  8. 8. Related work TriX, RDFXSLT: “alternative” RDF syntaxes in XML RDF Twig, TreeHugger: add intelligence to XSLT processors Topia: XSLT functions to query Sesame using pre-SPARQL languages XSPARQL: unification of SPARQL and XQuery in a single language 6
  9. 9. Scripting RDF transformations Many scripting languages have RDF APIs, but they’re not standard Coding transformations in script languages leads is messy (e.g.: Vapour) 7
  10. 10. XSLT+SPARQL Two sets of XPath functions to query RDF models using SPARQL Intended to be used in @select expressions of XSLT stylesheets Return plain, standard XML easily tractable with XSLT 8
  11. 11. Query results XML syntax <results> <result> <binding name=quot;fnamequot;><value>Tom</value>/binding> <binding name=quot;emailquot;><value>tom@example.org</value></binding> </result> <result> <binding name=quot;fnamequot;><value>Dick</value></binding> <binding name=quot;emailquot;><value>dick@example.org</value></binding> </result> </results> W3C Recommendation (Jan 2008) 9
  12. 12. Basic functions sparql:sparql(query [, documentUrl, ...]) sparql:sparqlEndpoint(query, endpointUrl) Execute SPARQL queries locally or remotely (endpoint) Model can be extended with “FROM” clauses 10
  13. 13. Advanced functions (I) Retrieving and parsing RDF data is expensive Advanced functions designed for: ‣ Efficently query the same model multiple times ‣ Create custom models programatically 11
  14. 14. Advanced functions (II) sparql’:parseString(string, syntax) Creates a model by parsing a string containg serialized RDF Support for different syntaxes: RDF/ XML, N3, TriX... 12
  15. 15. Advanced functions (III) sparql’:readModel(documentUrl, syntax) sparql’:readModel(nodeset) Create models by parsing: 1. A document retrieved from the web 2. An XML subtree (from the XSLT input document or even from the XSLT itself) 13
  16. 16. Advanced functions (IV) sparql’:mergeModels(model1, model2, ...) Combines two or more RDF models into a new one 14
  17. 17. Advanced functions (V) sparql’:sparqlModel(query, model) Executes a SPARQL query against an in-memory model 15
  18. 18. Two implementations 1. Java-based extension to Apache Xalan using Jena Exploits the extensibility of XSLT 2. Pure XSLT implementation Incomplete, XSLT “document()” cannot perform conneg 16
  19. 19. Applications of XSLT+SPARQL Transform RDF data for presentation in XHTML, SVG... Generate reports beyond SPARQL capabilities Develop scripts that retrieve and operate with RDF data from the (semantic) web 17
  20. 20. Example: Ivan’s acquittances <xsl:template match=quot;/quot;> <xsl:apply-templates select=quot;sparql:sparql(concat(sparql:commonPrefixes(), 'SELECT ?name ?mbox_sha1sum ?homepage FROM &lt;http://www.ivan-herman.net/foaf.rdf&gt; WHERE { &lt;http://www.ivan-herman.net/Ivan_Herman&gt; foaf:knows ?x . ?x foaf:name ?name . OPTIONAL { ?x foaf:mbox_sha1sum ?mbox_sha1sum . ?x foaf:homepage ?homepage }}'))quot;/> </xsl:template> <xsl:template match=quot;results:resultsquot;> <html> ... </html> </xsl:template> 18
  21. 21. Advanced examples Querying DBPedia endpoint HTML displays of SKOS thesauri Alphabetic display Systematic display (tree-like) “Spider” agent for LoD 19
  22. 22. Conclusions and future work XSLT+SPARQL overcomes the limitations of XSLT to process RDF XSLT+SPARQL can be used to write declarative scripts for the semantic web Future extensions: inference support 20
  23. 23. Thank you for your attention diego.berrueta@fundacionctic.org

×