{ and avoiding the xslt pilgrimagepolleres/presentations/... · xsparql traveling between the xml...

39
Traveling between the XML and RDF Worlds – and Avoiding the XSLT Pilgrimage Waseem Akhtar 1 Jacek Kopecký 3 Thomas Krennwallner 1, 2 Axel Polleres 1 1 Digital Enterprise Research Institute, National University of Ireland, Galway 2 Knowledge-Based Systems Group, Institute for Information Systems, TU Wien 3 STI Innsbruck, University of Innsbruck, Austria Knowledge-Based Systems Group KBS 1 / 12

Upload: others

Post on 25-Sep-2020

4 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL

Traveling between the XML and RDF Worlds– and Avoiding the XSLT Pilgrimage

Waseem Akhtar1 Jacek Kopecký3

Thomas Krennwallner1,2 Axel Polleres1

1Digital Enterprise Research Institute, National University of Ireland, Galway

2Knowledge-Based Systems Group, Institute for Information Systems, TU Wien

3STI Innsbruck, University of Innsbruck, Austria

!"#$ Knowledge-Based Systems GroupKBS

1 / 12

Page 2: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Alice, Bob, and Charles

knows knows

knows

2 / 12

Page 3: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Motivation

@prefix foaf: <http://xmlns.com/foaf/0.1/> ._:b1 a foaf:Person; foaf:name "Alice"; foaf:knows _:b2; foaf:knows _:b3._:b2 a foaf:Person; foaf:name "Bob"; foaf:knows _:b3._:b3 a foaf:Person; foaf:name "Charles".

<relations> <person name="Alice"> <knows>Bob</knows> <knows>Charles</knows> </person> <person name="Bob"> <knows>Charles</knows> </person> <person name="Charles"/> </relations>

relations.xml relations.rdf

relations

person personperson

name knows knows name nameknows

CharlesBobAlice Bob CharlesCharles

_:b1

foaf:Person

Alice

foaf:name

_:b2foaf:knows

Bob

foaf:name

_:b3foaf:knows

Charles

foaf:name

foaf:knows

rdf:type

rdf:typerdf:type

3 / 12

Page 4: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Motivation

@prefix foaf: <http://xmlns.com/foaf/0.1/> ._:b1 a foaf:Person; foaf:name "Alice"; foaf:knows _:b2; foaf:knows _:b3._:b2 a foaf:Person; foaf:name "Bob"; foaf:knows _:b3._:b3 a foaf:Person; foaf:name "Charles".

<relations> <person name="Alice"> <knows>Bob</knows> <knows>Charles</knows> </person> <person name="Bob"> <knows>Charles</knows> </person> <person name="Charles"/> </relations>

relations.xml relations.rdf

?

3 / 12

Page 5: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Motivation

I Two standards for different types of data: XML and RDF

I XML data model differs from RDF data model

I XML and RDF query languages have different objectives. . . but not so different at all.

4 / 12

Page 6: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery

XSLT, XQuery ?

RDF

XSLT, XQuery ? SPARQL

?

RDF + XML

? ?

Solved

XML

5 / 12

Page 7: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF

XSLT, XQuery ? SPARQL

?

RDF + XML

? ?

Tedious

XML

5 / 12

Page 8: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ?

SPARQL

?

RDF + XML

? ?

Issue: ambiguous XML representation of RDF

XML

5 / 12

Page 9: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ?

SPARQL

?

RDF + XML

? ?

Issue: extract the whole RDF store as XML

XML

5 / 12

Page 10: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ?

SPARQL

?

RDF + XML

? ?

Issue: higher entailment regime

XML

5 / 12

Page 11: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL

?

RDF + XML

? ?

construct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F} XML

5 / 12

Page 12: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML

? ?

construct { _:b foaf:name ?FN }from <vcard.rdf>where { ?P vc:FN ?FN }filter(?FN = concat("""",?N," ",?F,""""))

5 / 12

Page 13: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML

? ?

construct { _:b foaf:name ?? }from <vcard.rdf>where { ?P vc:Given ?N . ?P vc:Family ?F }filter(?FN = concat("""",?N," ",?F,""""))

5 / 12

Page 14: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML

? ?

construct { _:b foaf:name ?FN }from <vcard.rdf>where { ?P vc:Given ?N . ?P vc:Family ?F .filter(?FN = concat("""",?N," ",?F,"""")) }

5 / 12

Page 15: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML

? ?

construct { _:b foaf:name fn:concat("""",?N," ",?F,"""") }from <vcard.rdf>where { ?P vc:Given ?N . ?P vc:Family ?F }filter(?FN = concat("""",?N," ",?F,""""))

5 / 12

Page 16: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML ?

?

construct { _:b foaf:name concat("""",?N," ",?F,"""") }from <vcard.rdf>where { ?P vc:Given ?N . ?P vc:Family ?F }filter(?FN = concat("""",?N," ",?F,""""))

5 / 12

Page 17: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping between XML and RDF

tofrom

XML RDF

XML XSLT, XQuery XSLT, XQuery ?RDF XSLT, XQuery ? SPARQL ?RDF + XML ? ?

construct { _:b foaf:name concat("""",?N," ",?F,"""") }from <vcard.rdf>where { ?P vc:Given ?N . ?P vc:Family ?F }filter(?FN = concat("""",?N," ",?F,""""))

5 / 12

Page 18: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XQuery and SPARQL – A comparison

Schematic view on XQuery

Prolog: P declare namespaceprefix="namespace-URI"

Body: F for var in XPath-expressionL let var := XPath-expressionW where XPath-expressionO order by XPath-expression

Head: R return XML + nested XQuery

Schematic view on SPARQL

Prolog: P prefix prefix: <namespace-URI>Head: C construct { template }Body: D from / from named <dataset-URI>

W where { pattern }M order by expression

limit integer > 0offset integer > 0

6 / 12

Page 19: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL: Combining XQuery with SPARQL

Prolog: P declare namespace prefix="namespace-URI"or prefix prefix: <namespace-URI>

Body: F for var in XPath-expressionL let var := XPath-expressionW where XPath-expressionO order by expression orF’ for varlistD from / from named <dataset-URI>W where {pattern }M order by expression

limit integer > 0offset integer > 0

Head: C construct{ template (with nested XSPARQL) } or

R return XML + nested XSPARQL

7 / 12

Page 20: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to RDFGenerate fullname from first and last name:

construct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where {

$P vc:Given $N .$P vc:Family $F .

}

_:b1 foaf:name "Waseem Akhtar"_:b2 foaf:name "Jacek Kopecky"_:b3 foaf:name "Axel Polleres"...

8 / 12

Page 21: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to RDFGenerate fullname from first and last name:

construct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where {

$P vc:Given $N .$P vc:Family $F .

}

_:b1 foaf:name "Waseem Akhtar"_:b2 foaf:name "Jacek Kopecky"_:b3 foaf:name "Axel Polleres"...

8 / 12

Page 22: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 23: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 24: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 25: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 26: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 27: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Mapping RDF to XML

<relations>{for $Person $Namefrom <relations.rdf>where { $Person foaf:name $Name }order by $Namereturn <person name="{$Name}">{

for $FNamefrom <relations.rdf>where {

$Person foaf:knows $Friend .$Person foaf:name $Name .$Friend foaf:name $FName

}return <knows>{$FName}</knows>

}</person>}</relations>

<relations><person name="Alice"><knows>Bob</knows><knows>Charles</knows>

</person><person name="Bob"><knows>Charles</knows>

</person><person name="Charles"/>

</relations>

9 / 12

Page 28: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL Semantics + Implementation

I Formal semantics of XSPARQL: extension of the XQuery semantics byplugging in SPARQL semantics in a modular way

I Rewriting algorithm is defined for embedding XSPARQL into nativeXQuery plus interleaved calls to a SPARQL endpoint

I Benefits: rely on off-the-shelf components

I Ongoing work: Optimization

10 / 12

Page 29: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL Semantics + Implementation

I Formal semantics of XSPARQL: extension of the XQuery semantics byplugging in SPARQL semantics in a modular way

XMLor RDF

QueryRewriter

XQueryEngine

XMLor RDFXSPARQL

SPARQL Engine

I Rewriting algorithm is defined for embedding XSPARQL into nativeXQuery plus interleaved calls to a SPARQL endpoint

I Benefits: rely on off-the-shelf components

I Ongoing work: Optimization

10 / 12

Page 30: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL Semantics + Implementation

I Formal semantics of XSPARQL: extension of the XQuery semantics byplugging in SPARQL semantics in a modular way

XMLor RDF

QueryRewriter

XQueryEngine

XMLor RDFXSPARQL

SPARQL Engine

I Rewriting algorithm is defined for embedding XSPARQL into nativeXQuery plus interleaved calls to a SPARQL endpoint

I Benefits: rely on off-the-shelf components

I Ongoing work: Optimization

10 / 12

Page 31: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL Semantics + Implementation

I Formal semantics of XSPARQL: extension of the XQuery semantics byplugging in SPARQL semantics in a modular way

XMLor RDF

QueryRewriter

XQueryEngine

XMLor RDFXSPARQL

SPARQL Engine

I Rewriting algorithm is defined for embedding XSPARQL into nativeXQuery plus interleaved calls to a SPARQL endpoint

I Benefits: rely on off-the-shelf components

I Ongoing work: Optimization

10 / 12

Page 32: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

XSPARQL Semantics + Implementation

I Formal semantics of XSPARQL: extension of the XQuery semantics byplugging in SPARQL semantics in a modular way

XMLor RDF

QueryRewriter

XQueryEngine

XMLor RDFXSPARQL

SPARQL Engine

I Rewriting algorithm is defined for embedding XSPARQL into nativeXQuery plus interleaved calls to a SPARQL endpoint

I Benefits: rely on off-the-shelf components

I Ongoing work: Optimization

10 / 12

Page 33: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .return ( fn:concat("_:b",$aux_result_pos," foaf:name "),

( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )

11 / 12

Page 34: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .return ( fn:concat("_:b",$aux_result_pos," foaf:name "),

( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )

11 / 12

Page 35: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .return ( fn:concat("_:b",$aux_result_pos," foaf:name "),

( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )

11 / 12

Page 36: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .

return ( fn:concat("_:b",$aux_result_pos," foaf:name "),( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )

11 / 12

Page 37: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .return ( fn:concat("_:b",$aux_result_pos," foaf:name "),

( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )11 / 12

Page 38: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Rewriting XSPARQL to XQueryconstruct { _:b foaf:name {fn:concat("""",$N," ",$F,"""")} }from <vcard.rdf>where { $P vc:Given $N . $P vc:Family $F . }

let $aux_query := fn:concat("http://localhost:2020/sparql?query=",fn:encode-for-uri(

"select $P $N $F from <vcard.rdf>where {$P vc:Given $N. $P vc:Family $F.}"))

for $aux_result at $aux_result_posin doc($aux_query)//sparql_result:result

let $P_Node := $aux_result/sparql_result:binding[@name="P"]let $N_Node := $aux_result/sparql_result:binding[@name="N"]let $F_Node := $aux_result/sparql_result:binding[@name="F"]let $N := data($N_Node/*)let $N_NodeType := name($N_Node/*)let $N_RDFTerm := local:rdf_term($N_NodeType,$N). . .return ( fn:concat("_:b",$aux_result_pos," foaf:name "),

( fn:concat("""",$N_RDFTerm," ",$F_RDFTerm,"""") ), "." )11 / 12

Page 39: { and Avoiding the XSLT Pilgrimagepolleres/presentations/... · XSPARQL Traveling between the XML and RDF Worlds { and Avoiding the XSLT Pilgrimage WaseemAkhtar1 JacekKopecký3 ThomasKrennwallner1;2

Conclusion and Outlook

SPA QLML

XDF

R

I Querying XML and RDF at one shotI Producing XML or RDF from XML and/or RDFI Extending SPARQL by expressive XQuery constructsI Extending XQuery by SPARQL graph patterns

Ongoing work:I OptimizationI extend XSPARQL with nested FLWOR in where partI XSPARUL

http://xsparql.deri.org/12 / 12