simple rdf to xml data grounding

17
Copyright 2005 Digital Enterprise Research Institute. All rights reserved. www.deri.org Simple RDF to XML Data Grounding Jacek Kopecký

Upload: samantha-branch

Post on 01-Jan-2016

41 views

Category:

Documents


1 download

DESCRIPTION

Simple RDF to XML Data Grounding. Jacek Kopecký. What is Grounding?. Ways to go – direct. instance MrMoon memberOf Person firstName hasValue “Michael” lastName hasValue “Moon” … Michael - PowerPoint PPT Presentation

TRANSCRIPT

Copyright 2005 Digital Enterprise Research Institute. All rights reserved.

www.deri.org

Simple RDF to XML Data Grounding

Jacek Kopecký

2

What is Grounding?

3

Ways to go – direct

instance MrMoon memberOf Person

firstName hasValue “Michael” lastName hasValue “Moon” …

<person> <name> <first>Michael</first> <last>Moon</last> </name> …

direct mapping

4

Ways to go – semantic

instance _# memberOf Person instance MrMoon memberOf Personname hasValue _#2 firstName hasValue “Michael”

instance _#2 memberOf Name lastName hasValue “Moon”first hasValue “Michael” …last hasValue “Moon”

<person> <name> <first>Michael</first> <last>Moon</last> </name> …

(sem)automatic lifting, lowering

ontology mapping

5

Ways to go – XML

instance MrMoon memberOf Person firstName hasValue “Michael” lastName hasValue “Moon” …

<person> <rdf:RDF> <name> <Person rdf:ID=“MrMoon”> <first>Michael</first> <firstName>Michael</firstName> <last>Moon</last> <lastName>Moon</lastName> </name> </Person> … …

(de)serialization

XSLT

6

Our XML-based choice

• Lifting: XSLT is sufficient– Input data is nice XML– Output data is RDF/XML, quite flexible

• Lowering: SPARQL, then XSLT– Only XSLT would be hard– SPARQL is made for getting data from RDF– SPARQL cannot generate any XML– Transform the table of results into target XML

7

Lifting example

<xsl:template match=“/m:shipmentOrderResponse"> <rdf:RDF> <ex:Response> <ex:price><xsl:value-of select="m:price"/></ex:price> <ex:estimatedPickupDate> <xsl:value-of select="m:pickupDate"/> </ex:estimatedPickupDate> </ex:Response> </rdf:RDF></xsl:template>

8

Lowering example<lowering> <sparql> PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX foaf: <http://xmlns.com/foaf/0.1/> PREFIX ex: <http://example.com/shipping#>

SELECT DISTINCT ?fromFn ?fromLn ?fromPhone ?fromEmail ?fromFax ?fromStr ?fromCity ?fromZip ?fromState ?fromCountry ?toFn ?toLn ?toStr ?toCity ?toState ?toZip ?toCountry ?package ?q ?weight ?length ?height ?width ?pickupStart ?pickupEnd WHERE { ?x rdf:type ex:Order ; ex:fromAddr ?fromA ; ex:fromContact ?fromC ; ex:toAddr ?toA ; ex:toContact ?toC ; ex:package ?package ; ex:pickupFrom ?pickupStart ; ex:pickupTo ?pickupEnd . ?fromA ex:firstName ?fromFn ; ex:lastName ?fromLn ; ex:street ?fromStr ; ex:city ?fromCity ; ex:zip ?fromZip ; ex:country ?fromCountry . OPTIONAL { ?fromA ex:state ?fromState . } ?fromC ex:phone ?fromPhone ; ex:email ?fromEmail ; ex:fax ?fromFax . ?toA ex:firstName ?toFn ; ex:lastName ?toLn ; ex:street ?toStr ; ex:city ?toCity ; ex:zip ?toZip ; ex:country ?toCountry . OPTIONAL { ?toA ex:state ?toState . } ?package ex:quantity ?q ; ex:weight ?weight ; ex:height ?height ; ex:width ?width ; ex:length ?length . } </sparql>

<xsl:stylesheet version="1.0" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:owl="http://www.w3.org/2002/07/owl#" xmlns:rdfs="http://www.w3.org/2000/01/rdf-schema#" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:ex="http://example.com/shipping#" xmlns:sp="http://www.w3.org/2005/sparql-results#" xmlns:m="http://www.example.org/muller/" >

<xsl:template match="/"> <xsl:apply-templates select="/sp:sparql/sp:results"/> </xsl:template>

<xsl:template match="sp:results"> <m:shipmentOrderRequest> <m:addressFrom> <m:firstname><xsl:value-of select="sp:result[1]/sp:binding[@name='fromFn']/sp:literal"/></m:firstname> <m:lastname><xsl:value-of select="sp:result[1]/sp:binding[@name='fromLn']/sp:literal"/></m:lastname> <m:address><xsl:value-of select="sp:result[1]/sp:binding[@name='fromStr']/sp:literal"/>, <xsl:value-of select="sp:result[1]/sp:binding[@name='fromCity']/sp:literal"/></m:address> <m:location> <m:postalCode><xsl:value-of select="sp:result[1]/sp:binding[@name='fromZip']/sp:literal"/></m:postalCode> <m:country><xsl:value-of select="sp:result[1]/sp:binding[@name='fromCountry']/sp:literal"/></m:country> <m:state><xsl:value-of select="sp:result[1]/sp:binding[@name='fromState']/sp:literal"/></m:state> </m:location> <m:contactInformation> <m:phone><xsl:value-of select="sp:result[1]/sp:binding[@name='fromPhone']/sp:literal"/></m:phone> <m:EMail><xsl:value-of select="sp:result[1]/sp:binding[@name='fromEmail']/sp:literal"/></m:EMail> <m:fax><xsl:value-of select="sp:result[1]/sp:binding[@name='fromFax']/sp:literal"/></m:fax> </m:contactInformation> </m:addressFrom> <m:shipmentDate> <m:earliestPickupDate><xsl:value-of select="sp:result[1]/sp:binding[@name='pickupStart']/sp:literal"/></m:earliestPickupDate> <m:latestPickupDate><xsl:value-of select="sp:result[1]/sp:binding[@name='pickupEnd']/sp:literal"/></m:latestPickupDate> </m:shipmentDate> <xsl:apply-templates select="sp:result"/> <m:addressTo> <m:firstname><xsl:value-of select="sp:result[1]/sp:binding[@name='toFn']/sp:literal"/></m:firstname> <m:lastname><xsl:value-of select="sp:result[1]/sp:binding[@name='toLn']/sp:literal"/></m:lastname> <m:address><xsl:value-of select="sp:result[1]/sp:binding[@name='toStr']/sp:literal"/>, <xsl:value-of select="sp:result[1]/sp:binding[@name='toCity']/sp:literal"/></m:address> <m:location> <m:postalCode><xsl:value-of select="sp:result[1]/sp:binding[@name='toZip']/sp:literal"/></m:postalCode> <m:country><xsl:value-of select="sp:result[1]/sp:binding[@name='toCountry']/sp:literal"/></m:country> <m:state><xsl:value-of select="sp:result[1]/sp:binding[@name='toState']/sp:literal"/></m:state> </m:location> </m:addressTo> </m:shipmentOrderRequest> </xsl:template>

<xsl:template match="sp:result"> <m:packageInformation> <m:quantity><xsl:value-of select="sp:binding[@name='q']/sp:literal"/></m:quantity> <m:weight><xsl:value-of select="sp:binding[@name='weight']/sp:literal"/></m:weight> <m:length><xsl:value-of select="sp:binding[@name='length']/sp:literal"/></m:length> <m:height><xsl:value-of select="sp:binding[@name='height']/sp:literal"/></m:height> <m:width><xsl:value-of select="sp:binding[@name='width']/sp:literal"/></m:width> </m:packageInformation> </xsl:template>

</xsl:stylesheet></lowering>

9

Structure of lowering

<lowering>

<sparql>

</sparql>

<xsl:stylesheet>

</xsl:stylesheet>

</lowering>

10

The SPARQL looks like this:

SELECT DISTINCT ?fromFn ?fromLn ?fromPhone ?fromEmail ?fromFax ?fromStr ?fromCity ?fromZip ?fromState ?fromCountry ?toFn ?toLn ?toStr ?toCity ?toState ?toZip ?toCountry ?package ?q ?weight ?length ?height ?width ?pickupStart ?pickupEnd WHERE { ?x rdf:type ex:Order ; ex:fromAddr ?fromA ; ex:package ?package ; ex:pickupFrom ?pickupStart ; ex:pickupTo ?pickupEnd . ?fromA ex:firstName ?fromFn ; ex:lastName ?fromLn ; ex:street ?fromStr ; …

Not too pretty

11

The XSLT looks like this:

<xsl:template match="sp:results"> <m:shipmentOrderRequest> <m:addressFrom> <m:firstname> <xsl:value-of select="sp:result[1]/sp:binding[@name='fromFn']/sp:literal"/> </m:firstname> <m:lastname> <xsl:value-of select="sp:result[1]/sp:binding[@name='fromLn']/sp:literal"/> </m:lastname>…

Not too pretty

12

Comparing to Uni Jena DSD

SPARQL

XSLT

XML template

DSD mappings

13

Limitation

• SPARQL results table a rectangle– Repetition of chunks means repetition of

whole lines– Easy to handle for a single repeating piece– Probably easy for embedded repeating pieces– Probably way harder for parallel repeats

14

WSMO? WSML?

• This is based on RDF, RDF/XML• WSML has RDF syntax and RDF form

– Can be converted automatically– And lifting can go to almost anything

• And WSML has a query language– Can be embedded in <lowering>

• Attaching grounding to WSMO descriptions– SAWSDL to the rescue

15

Quasi-evaluation

• The only grounding I found out there is DSD– SWS challenge: delivery services– SPARQL+XSLT is shorter– The SPARQL part is probably worse than their

strange syntax

• Implementing <lowering> is trivial• It works, it was done quickly, it may be inefficient

16

Vision

• Semantic-level mappings– Automatic lifting from XML Schema– Or guided manual lifting– Resulting ontology may be useful

• SPARQL method CONSTRUCTXML– CONSTRUCT creates a graph, we need XML– Would need to be recursive

17

Discussion

• Anybody interested?– In using the stuff we have?– In helping with the semantic-level lifting?– In working on SPARQL CONSTRUCTXML?