Combining XML querying Combining XML querying with ontology reasoning: with ontology reasoning: Xcerpt and DIG Xcerpt and DIG Wlodek Drabent Artur Wilk Ontology and Rule Integration Workshop Athens, GA November 2006
The problem � Combining XML queries with ontology queries � Example � XML document containing recipes � Ontology � classifies ingredients � relates ingredients with vitamins � Queries recipes.xml � Find gluten free recipes (answer filtering) � List recipes together with vitamins they contain (data enhancement) � Goal: a hybrid system answering combined queries
The approach � XML query language � Ontology reasoner combined query � XML interface: DIG control system XML DIG queries and answers expressions XML query language ontology engine reasoner XML data ontology November 11th, 2006
The approach ( cont .) � ordinary XML query � extended XML query programs programs handled by a control system which � � communicates with reasoner � calls XML query engine to execute (parts of) programs ontology reasoner DIG queries DIG responses XML data XML data ontology
The approach: instantiation � XML query language � Xcerpt � simple structure of programs: rules � simple (fixpoint) semantics � Ontology reasoner � any supporting DIG e.g. Racer � Control system � Extended Xcerpt November 11th, 2006
Outline � Preliminaries � Xcerpt � DIG interface � Extended Xcerpt � syntax and semantics � program examples � Conclusions November 11th, 2006
Xcerpt - Introduction Xcerpt – query and transformation language for XML [Schaffert et al ., 2004] � inspired by logic programming � uses pattern matching instead of path navigation November 11th, 2006
Xcerpt: Core concepts � data terms model XML documents � <CD> <title> Stop </title> </CD> CD[ title[ “ Stop ” ] ] � query terms patterns used to match data terms � � successful matching results in variable bindings (answer substitutions) CD[ title [ X ] ] CD[ title[ “ Stop ” ] ] { X / “ Stop ” } matches � construct terms used to build data terms (by applying answer substitutions) �
Xcerpt programs � consist of query rules c ← Q the body Q � � used to extract XML data � consists of query terms connected by and , or … � possibly associated with external resources � the head c � � a construct term � used to build new XML data Xcerpt syntax � CONSTRUCT GOAL c c FROM FROM Q Q END END
Xcerpt query rules - example Data term: catalogue[ cd[ title[ "Empire Burlesque“ ], artist[ "Bob Dylan“ ], year[ "1985“ ] ], cd[ title[ ], artist[ " Bonnie Tyler“ ], year[ "1988“ ] ], "Hide your heart“ cd[ title[ ], artist[ "Sam Brown“ ], year[ "1988“ ] ] "Stop“ ] title [ TITLE ] ← cd[[ title[ TITLE ], year[ "1988“ ] ]] desc Answers : { TITLE / "Hide your heart" }, { TITLE / ”Stop" } Result : title [ "Hide your heart" ] title [ "Stop” ]
DIG interface � an XML interface to Description Logics systems by the D L I mplementation G roup [S. Bechhofer] � � XML encoded messages (statements) Tell : managing the knowledge base � Ask : querying the knowledge base � Response : replying to the queries � <children> Ask <catom name=“ gluten-containing ”/> </children> <conceptSet> <synonyms> <catom name=“ flour ”/> </synonyms> Response <synonyms> <catom name=“ spaghetti ”/> </synonyms> </conceptSet> November 11th, 2006
Extended Xcerpt � Xcerpt + ontology reasoner interface � communication with a reasoner by DIG Control system handling Extended Xcerpt programs DIG statements Xcerpt Ontology engine reasoner November 11th, 2006
Extended Xcerpt programs � adding to Xcerpt � DIG ask rules � produce intermediate results (ontology queries) to be sent to reasoner ontology reasoner rule � DIG response rules DIG ask DIG ask rule � query reasoner statements responses rule DIG response DIG response rule statements goal rule XML data ontology November 11th, 2006
Extended Xcerpt: syntax the same as Xcerpt syntax � some Xcerpt rules distinguished as DIG rules � # l [ a,c ] ← … DIG ask rules � � produce data terms # l [ a i ,c i ] a i - DIG ask statement c i - a context (to pass data associated with the ask statement) … ← … # l [ q a ,q c ] … DIG response rules � q a – query term matching DIG responses q c – query term matching the context rule chaining based on ordinary rule dependence � restriction: no DIG rule depends on itself �
Extended Xcerpt: operational semantics Evaluate successively the rules of a program: To obtain results of # l [ a,c ] ← … a DIG ask rule …………..….…………..……. � evaluate it in the standard way � # l [ a 1 ,c 1 ] … # l [ a n ,c n ] to obtain data terms….............………...… a 1 , … , a n send DIG ask statements………………… � Ontology reasoner to the reasoner to obtain replies………………..………….. r 1 , … , r n build facts …........................................…. # l [ r 1 ,c 1 ] … # l [ r n ,c n ] � any other Xcerpt rule (including a DIG response rule) � use the standard Xcerpt evaluation method �
Answer filtering – example Query: Find recipes with ingredients containing gluten recipes.xml: GOAL bad-recipes[ all var R ] recipes[ DIG FROM recipe[ #gluten [ response name[ " Recipe1 " ], ingredients[ ingr[ name[ " sugar " ] ], true[[ ]], rule name[ var R ] ] ingr[ name[ " orange " ] ] ], END recipe[ name[ " Recipe2 " ], CONSTRUCT CONSTRUCT ingredients[ ingr[ name[ " flour " ] ], Ask statements and their contexts: #gluten [ false [ attr{ id[“1”]} ], name[ “Recipe1” ] ] #gluten [ ingr[ name[ " salt " ] ] ] ] subsumes [ attr{ id[“1”] }, END subsumes[ catom[ attr{ name[" gluten-containing "] } ] CONSTRUCT Answer substitutions (for the ask rule) : catom[ attr{ name["gluten-containing"] } ] catom[ attr{ name[ “ sugar ” ] } ] ] Facts representing reasoner answers: #gluten [ false [ attr{ id[“2”]} ], name[ “Recipe1” ] ] DIG catom[ attr{ name[ var N ] } ] ], name[ “Recipe1” ] R N result: END name[ var R ] ] subsumes [ attr{ id[“2”] }, #gluten[ false [ attr{ id[“1”]} ], name[ “ Recipe1 ” ] ] ask CONSTRUCT FROM catom[ attr{ name[" gluten-containing "] } ] “Recipe1” #gluten[ false [ attr{ id[“2”]} ], name[ “ Recipe1 ” ] ] rule “sugar” bad-recipes [ “Recipe2”] #gluten [ true [ attr{ id[“3”]} ], name[ “Recipe2” ] ] in[ resource[ "file:recipes.xml" ], catom[ attr{ name[ “ orange ” ] } ] ] “Recipe1” #gluten[ true [ attr{ id[“3”]} ], name[ “ Recipe2 ” ] ] Reasoner answers and their contexts: “orange” name[ “Recipe1” ] END desc recipe[ “flour” subsumes [ attr{ id[“3”] }, “Recipe2” #gluten[ false [ attr{ id[“4”]} ], name[ “ Recipe2 ” ] ] false[ attr{ id[“1”] } ] name[ “Recipe1” ] CONSTRUCT name[ var R ], catom[ attr{ name[" gluten-containing "] } ] “salt” “Recipe2” #gluten [ false [ attr{ id[“4”]} ], name[ “Recipe2” ] ] desc ingr[ name[ var N ] ] ] ] false[ attr{ id[“2”] } ] name[ “Recipe1” ] catom[ attr{ name[ “ flour ” ] } ] ] END END true [ attr{ id[“3”] } ] name[ “Recipe2” ] name[ “Recipe2” ] subsumes [ attr{ id[“4”] }, false[ attr{ id[“4”] } ] name[ “Recipe2” ] catom[ attr{ name[" gluten-containing "] } ] catom[ attr{ name[ “ salt ” ] } ] ] name[ “Recipe2” ]
Recommend
More recommend