1 querying xml: xquery h. schweppe und t. schlieder literatur: a. deutsch et. al. "a query...
TRANSCRIPT
1
Querying XML: XqueryQuerying XML: XqueryH. Schweppe und T. SchliederH. Schweppe und T. Schlieder
Literatur:Literatur:• A. Deutsch et. al. "A Query Language for XML"A. Deutsch et. al. "A Query Language for XML"
(www.w3.org/TR/NOTE-xml-ql-19980819)(www.w3.org/TR/NOTE-xml-ql-19980819)
• Jonathan Robie (ed.) "XQL (XML Query Language)"Jonathan Robie (ed.) "XQL (XML Query Language)"
(metalab.unc.edu/xql/xql-proposal.xml)(metalab.unc.edu/xql/xql-proposal.xml)
• A. Bonifati, S. Ceri: "Comparative Analysis of Five A. Bonifati, S. Ceri: "Comparative Analysis of Five
XML Query Languages" XML Query Languages" (SIGMOD Record, März 2000)(SIGMOD Record, März 2000)
• Fankhauser, P., Wadler, P.: XQuery TutorialFankhauser, P., Wadler, P.: XQuery Tutorial
2
GliederungGliederung
• MotivationMotivation– Warum eigentlich XML-Anfragen??Warum eigentlich XML-Anfragen??– Einsatzgebiete von XML-AnfragesprachenEinsatzgebiete von XML-Anfragesprachen– Unterschied zu SQL/OQLUnterschied zu SQL/OQL
• Anfragesprachen für XMLAnfragesprachen für XML– HauptbestandteileHauptbestandteile– Reguläre PfadausdrückeReguläre Pfadausdrücke– SortierenSortieren– Quantifizierung, NegationQuantifizierung, Negation– SubqueriesSubqueries– Kombinieren von Quellen (Joins)Kombinieren von Quellen (Joins)– BewertungBewertung
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
3
Warum Query Languages für Warum Query Languages für XML?XML?
• Daten-ExtraktionDaten-Extraktion"Liefere alle Autoren aller Bücher""Liefere alle Autoren aller Bücher"
• Daten-TransformationDaten-Transformation"Erstelle ein neues Dokument mit den Autoren "Erstelle ein neues Dokument mit den Autoren aller Bücher"aller Bücher"
• Daten-KonversionDaten-Konversion""Restrukturiere ein XML-Dokument exportiert von Restrukturiere ein XML-Dokument exportiert von einem RDBMS in ein Dokument zum Import in ein einem RDBMS in ein Dokument zum Import in ein OODBMS"OODBMS"
• Daten-IntegrationDaten-Integration""Erstelle eine Sicht auf Daten, die zu Erstelle eine Sicht auf Daten, die zu unterschiedlichen DTDs gehören"unterschiedlichen DTDs gehören"
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
4
Warum nicht SQL/OQL Warum nicht SQL/OQL verwenden?verwenden?• Relationale/objektorientierte Daten sind Relationale/objektorientierte Daten sind
wohlstrukturiert:wohlstrukturiert:– Vorgegebenes SchemaVorgegebenes Schema– Daten werden passend zu Schema importiertDaten werden passend zu Schema importiert
• XML-Dokumente sind oft semistrukturiert:XML-Dokumente sind oft semistrukturiert:– Kein Schema vorhanden (Dokumente ohne DTD)Kein Schema vorhanden (Dokumente ohne DTD)– Wenig restriktive DTDWenig restriktive DTD
• SQL: Keine Unterstützung für BaumstrukturSQL: Keine Unterstützung für Baumstruktur• Keine/unzureichende Möglichkeiten, Schema-Keine/unzureichende Möglichkeiten, Schema-
Informationen anzufragenInformationen anzufragen• Keine/unzureichende Konstruktions-Keine/unzureichende Konstruktions-
OperatorenOperatoren• Keine SQL/OQL-Konstrukte zur Integration Keine SQL/OQL-Konstrukte zur Integration
von verschiedenen Quellenvon verschiedenen Quellen
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
5
BeispielBeispiel
"Erstelle eine Liste aller Abbildungen eines "Erstelle eine Liste aller Abbildungen eines Buches"Buches"
<figlist> <figlist> { for $f in document("book1.xml")//figure { for $f in document("book1.xml")//figure return <figure> return <figure> { $f/@* } { $f/@* } { $f/title }{ $f/title } </figure> } </figure> } </figlist> </figlist>
Selektion und Transformation!Selektion und Transformation!
6
Ergebnis: ein XML-Dokument, das so aussehen könnteErgebnis: ein XML-Dokument, das so aussehen könnte <figlist><figlist> <figure<figure height="400" width="400"> height="400" width="400">
<title>Traditional client/server <title>Traditional client/server architecturearchitecture </title> </title>
</figure></figure> <figure<figure height="200" width="500"> height="200" width="500">
<title>Graph representations of <title>Graph representations of structuresstructures </title> </title>
</figure</figure> > <figure<figure height="250" width ="400"> height="250" width ="400">
<title>Examples of Relations<title>Examples of Relations </title> </title> </figure></figure> </figlist> </figlist>
7
Anfragesprachen für XMLAnfragesprachen für XML
Vorgestellt und verglichen werdenVorgestellt und verglichen werden• XML-QLXML-QL
A. Deutsch, M. Fernandez, D. Florescu, A. Levy, D. A. Deutsch, M. Fernandez, D. Florescu, A. Levy, D. SuciuSuciuwww.w3.org/TR/NOTE-xml-ql-19980819www.w3.org/TR/NOTE-xml-ql-19980819
• XQLXQLJ. Robie (editor)J. Robie (editor)metalab.unc.edu/xql/xql-proposal.xmlmetalab.unc.edu/xql/xql-proposal.xml
• XQueryXQuery
W3C XML Query pageW3C XML Query page
http://http://wwwwww.w3..w3.orgorg/XML/Query./XML/Query.htmlhtml
http://www.research.avayalabs.com/~wadler/xml/http://www.research.avayalabs.com/~wadler/xml/
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
8
Hauptbestandteile der Hauptbestandteile der SprachenSprachen• PatternPattern clause clause
– Matchen von (verschachtelten) ElementenMatchen von (verschachtelten) Elementen– Binden von VariablenBinden von Variablen
• FilterFilter clause clause– Vergleichen von Variablen mit Konstanten und Vergleichen von Variablen mit Konstanten und
VariablenVariablen
• ConstructorConstructor clause clause– Erzeugen von neuen XML-DokumentenErzeugen von neuen XML-Dokumenten
Xquery, XML-QL unterstützen alle drei Xquery, XML-QL unterstützen alle drei Konstrukte.Konstrukte.
XQL unterstützt Patterns und Filters, sowie XQL unterstützt Patterns und Filters, sowie implizit auch Constructors implizit auch Constructors (renaming, grouping)(renaming, grouping)
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
9
XQuery – die Sprache des XQuery – die Sprache des WebWebBeispieldatenBeispieldaten<bib> <bib> <book year="1999" isbn="1-55860-622-X"> <book year="1999" isbn="1-55860-622-X">
<title>Data on the Web</title> <title>Data on the Web</title> <author>Abiteboul</author> <author>Abiteboul</author> <author>Buneman</author> <author>Buneman</author> <author>Suciu</author> <author>Suciu</author>
</book> </book> <book year="2001" isbn="1-XXXXX-YYY-<book year="2001" isbn="1-XXXXX-YYY-
Z"> Z"> <title>XML Query</title> <title>XML Query</title> <author>Fernandez</author> <author>Fernandez</author> <author>Suciu</author> <author>Suciu</author>
</book></book> </bib></bib>
Datenmodell / SyntaxDatenmodell / SyntaxXMLXML Schema Schema <xsd:group name="Bib"> <xsd:group name="Bib"> <xsd:element name="bib"> <xsd:element name="bib"> <xsd:complexType> <xsd:complexType> <xsd:group ref="Book" minOccurs="0" <xsd:group ref="Book" minOccurs="0"
maxOccurs="unbounded"/> maxOccurs="unbounded"/> </xsd:complexType> </xsd:complexType> </xsd:element> </xsd:element> </xsd:group> </xsd:group> <xsd:group name="Book"> <xsd:group name="Book"> <xsd:element name="book"> <xsd:element name="book"> <xsd:complexType> <xsd:complexType> <xsd:attribute name="year" type="xsd:integer"/> <xsd:attribute name="year" type="xsd:integer"/>
<xsd:attribute name="isbn" type="xsd:string"/> <xsd:attribute name="isbn" type="xsd:string"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="title" type="xsd:string"/> <xsd:element name="author" type="xsd:string" <xsd:element name="author" type="xsd:string" maxOccurs="unbounded"/> maxOccurs="unbounded"/>
</xsd:complexType> </xsd:complexType> </xsd:element> </xsd:element> </xsd:group> </xsd:group>
11
XQuery Algebra XQuery Algebra RepräsentationRepräsentation
type Bib = type Bib = bib [ Book{0, *} ] bib [ Book{0, *} ] type Book = book [ type Book = book [ @year [ Integer ] & @year [ Integer ] & @isbn [ String ], @isbn [ String ], title [ String ], title [ String ], author [ String ]{1, *} ] author [ String ]{1, *} ] let bib0 : Bib = bib let bib0 : Bib = bib [ book [ @year [ 1999 ], [ book [ @year [ 1999 ], @isbn [ "1-55860-622-X" ], @isbn [ "1-55860-622-X" ], title [ "Data on the Web" ], title [ "Data on the Web" ], author [ "Abiteboul" ], author [ "Abiteboul" ], author [ "Buneman" ], author [ "Buneman" ], author [ "Suciu" ] ], author [ "Suciu" ] ], book [ @year [ 2001 ], @isbn [ "1-XXXXX-YYY-Z" ], title [ "XML book [ @year [ 2001 ], @isbn [ "1-XXXXX-YYY-Z" ], title [ "XML
Query" ], author [ "Fernandez" ], author [ "Suciu" ] ] Query" ], author [ "Fernandez" ], author [ "Suciu" ] ] ] ]
12
XQuery und SchemataXQuery und Schemata
Autoren und Bücher, die vor 2000 veröffentlich wurdenAutoren und Bücher, die vor 2000 veröffentlich wurden
schema http://www.example.com/booksschema http://www.example.com/books
namespace default = http://www.example.com/booksnamespace default = http://www.example.com/books
validatevalidate
<BOOKS>{<BOOKS>{
for $book in /BOOKS/BOOK[@YEAR < 2000] returnfor $book in /BOOKS/BOOK[@YEAR < 2000] return
<BOOK>{ $book/AUTHOR, $book/TITLE }</BOOK><BOOK>{ $book/AUTHOR, $book/TITLE }</BOOK>
}</BOOKS>}</BOOKS>
13
XQueryXQuery
• GrundstrukturGrundstruktur ForFor Binden von Variablen an Mengen Binden von Variablen an Mengen For $t in document(For $t in document(http://...http://...) )
LetLet Binden eines Wertes an VariableBinden eines Wertes an Variable For $t = document(For $t = document(http://...http://...) )
WhereWhere Prädikat, wird je gebundenem Wert Prädikat, wird je gebundenem Wert
evaluiert evaluiert where where $t/$t/bookbook/@/@priceprice = "20" = "20"
Return Return Ergebniskonstruktor (manchmal: Ergebniskonstruktor (manchmal: dodo))
return $t/book/titlereturn $t/book/title SORTBY ($t/book/@price) SORTBY ($t/book/@price)
14
ProjektionProjektion
Finde alle Autoren aller BücherFinde alle Autoren aller Bücher
//bib0/book/authorbib0/book/author
==> ==> author [ "Abiteboul" ], author [ "Abiteboul" ],
author [ "Buneman" ], author [ "Buneman" ],
author [ "Suciu" ],author [ "Suciu" ],
author [ "Fernandez" ], author [ "Fernandez" ],
author [ "Suciu" ] author [ "Suciu" ]
: author [ String ] {0, *} : author [ String ] {0, *} ::type of resulttype of result
Äquivalent zu entsprechendem XML-Äquivalent zu entsprechendem XML-DokumentDokument
15
Atomare DatenAtomare Daten
Alle Autoren, aber als WerteAlle Autoren, aber als Werte
book0/author/data()book0/author/data()
==> ==> "Abiteboul", "Abiteboul",
"Buneman","Buneman",
"Suciu" "Suciu"
: String {1, *} : String {1, *}
book0/@year/data()book0/@year/data()
==> 1999 : Integer ==> 1999 : Integer
Auch Benutzerdefinierte Auch Benutzerdefinierte Funktionen erlaubt!Funktionen erlaubt!
16
IterationIteration
forfor b in bib0/book b in bib0/book returnreturn book [ b/author, b/title ]book [ b/author, b/title ] ==> book [ ==> book [ author [ "Abiteboul" ], author [ "Abiteboul" ], author [ "Buneman" ], author [ "Buneman" ], author [ "Suciu" ], author [ "Suciu" ], title [ "Data on the Web" ] ], title [ "Data on the Web" ] ], book book [ author [ "Fernandez" ], [ author [ "Fernandez" ], author [ "Suciu" ], author [ "Suciu" ], title [ "XML Query" ] ] title [ "XML Query" ] ] : book [ author[ String ]{1, *}, : book [ author[ String ]{1, *},
title[ String ] ]{0, *} title[ String ] ]{0, *}
Semantisch wie "list Semantisch wie "list comprehension" (siehe Haskell):comprehension" (siehe Haskell):[(b.a,b.t)| b <- [book] ] where [(b.a,b.t)| b <- [book] ] where book... book...
17
TypableitungTypableitung
bib0/book : Book{0, *} bib0/book : Book{0, *}
b : Book b : Book
b/author : author [ String ]{1, *} b/author : author [ String ]{1, *}
b/title : title [ String ] b/title : title [ String ]
Type inference =>Type inference =>
: book [ author[ String ]{1, *}, title[ String ] ]: book [ author[ String ]{1, *}, title[ String ] ]{0, *}{0, *}
18
FilterFilter
• filter filter selektiert Teile des Arguments selektiert Teile des Arguments (eines xml-Baums) (eines xml-Baums)
Beispiel: Inhaltsverzeichnis: Beispiel: Inhaltsverzeichnis: <toc> { filter(document<toc> { filter(document ("cookbook.xml") //("cookbook.xml") // (section | section/title | section/title/text())) } (section | section/title | section/title/text())) } </toc></toc>
19
SelektionSelektion
Bücher mit allen Elementen, die vor 2000 Bücher mit allen Elementen, die vor 2000 publiziert wurdenpubliziert wurden
for b in bib0/book for b in bib0/book wherewhere b/@year/data() <= 2000 b/@year/data() <= 2000 returnreturn
b b ==> book [ ==> book [
@year [ 1999 ], @year [ 1999 ], @isbn [ "1-55860-622-X" ], @isbn [ "1-55860-622-X" ], title [ "Data on the Web" ], title [ "Data on the Web" ], author [ "Abiteboul" ], author author [ "Abiteboul" ], author
[ "Buneman" ], [ "Buneman" ], author [ "Suciu" ] ] author [ "Suciu" ] ] : Book{0, *} : Book{0, *}
20
QuantifizierungQuantifizierung
Bücher, bei denen ein Autor "B..." heißt.Bücher, bei denen ein Autor "B..." heißt.
for b in bib0/book for b in bib0/book return return for a in distinct(b/author/data())for a in distinct(b/author/data()) where a = "Buneman" where a = "Buneman" returnreturn b b ==> book [ ==> book [
@year [ 1999 ],@year [ 1999 ], @isbn [ "1-55860-622-X" ], @isbn [ "1-55860-622-X" ],
title [ "Data on the Web" ], title [ "Data on the Web" ], author [ "Abiteboul" ], author [ "Abiteboul" ], author [ "Buneman" ], author [ "Suciu" ] ] author [ "Buneman" ], author [ "Suciu" ] ]
: Book{0, *} : Book{0, *}
21
Negierter ExistenzquntorNegierter Existenzquntor
Bücher, von denen "B..." kein Autor ist.Bücher, von denen "B..." kein Autor ist.for b in bib0/bookfor b in bib0/book return return where where emptyempty (for a in b/author (for a in b/author where a/data() = "Buneman" where a/data() = "Buneman" return return a) a) returnreturn b b ==> book [ ==> book [ @year [ 2001 ], @year [ 2001 ],
@isbn [ "1-XXXXX-YYY-Z" ], @isbn [ "1-XXXXX-YYY-Z" ], title [ "XML Query" ],title [ "XML Query" ], author [ "Fernandez" ], author author [ "Fernandez" ], author
[ "Suciu" ] [ "Suciu" ] ] : Book{0, *}] : Book{0, *}
22
...Quantifizierung...Quantifizierung
Alle Bücher, bei denen nur "B..." Autor Alle Bücher, bei denen nur "B..." Autor ist.ist.
for b in bib0/book for b in bib0/book returnreturn wwherehere emptyempty (for a in b/author (for a in b/author where a/data() <> "Buneman" where a/data() <> "Buneman" return return a) a) return return b b
==> () : Book{0, *}==> () : Book{0, *}
23
Binden von Werten (let) Binden von Werten (let)
Äquivalente Formulierung: Äquivalente Formulierung:
for b in bib0/book for b in bib0/book let nonbunemans = let nonbunemans =
(for a in b/author (for a in b/author where a/data() <> "Buneman" where a/data() <> "Buneman"
return return a) a)
where empty(nonbunemans) where empty(nonbunemans) returnreturn b b
24
VerbundVerbund
Erweitertes SchemaErweitertes Schematype Reviews =type Reviews =
reviews [ reviews [
book [ book [
title [ String ], title [ String ],
review [ String ] review [ String ]
]] {0, *} ] {0, *} ]
let review0 : Reviews = let review0 : Reviews =
reviews [ book [ title [ "XML Query" ], reviews [ book [ title [ "XML Query" ],
review [ "A darn fine book." ] ], review [ "A darn fine book." ] ],
book [ title [ "Data on the Web" ], book [ title [ "Data on the Web" ],
review [ "This is great!" ] ] ] review [ "This is great!" ] ] ]
25
Verbund (inner join)Verbund (inner join)
Titel, Autor und Review für jedes BuchTitel, Autor und Review für jedes Buch
for b in bib0/book for b in bib0/book return return
for r in review0/book for r in review0/book
where b/title/data() = r/title/data() where b/title/data() = r/title/data() returnreturn
book [ b/title, b/author, r/review ] book [ b/title, b/author, r/review ]
Wie "nested loop-join", Wie "nested loop-join", Semantik – nicht notwendig AusführungSemantik – nicht notwendig Ausführung
26
Restrukturierung und Restrukturierung und GruppierungGruppierung
Buchtitel gruppiert nach Autor. Buchtitel gruppiert nach Autor.
for a in for a in distinct(bib0/book/author/data()) distinct(bib0/book/author/data())
biblio [ biblio [
author[a], author[a],
for b in bib0/book for b in bib0/book return return
for a2 in b/author/data() for a2 in b/author/data()
where a = a2 where a = a2 returnreturn
b/title b/title ]]
27
XPath und XQueryXPath und XQuery
Return all authors of all booksReturn all authors of all books
/BOOKS/BOOK/AUTHOR/BOOKS/BOOK/AUTHOR
==
for $dot1 in $root/BOOKS for $dot1 in $root/BOOKS return return
for $dot2 in $dot1/BOOK returnfor $dot2 in $dot1/BOOK return
$dot2/AUTHOR$dot2/AUTHOR
28
UmformungsregelnUmformungsregeln
AssociativitAssociativitätät in XPath in XPath
BOOKS/(BOOK/AUTHOR)BOOKS/(BOOK/AUTHOR)
==
(BOOKS/BOOK)/AUTHOR(BOOKS/BOOK)/AUTHOR
AssociativitAssociativitätät in XQuery in XQuery
for $dot1 in $root/BOOKS returnfor $dot1 in $root/BOOKS return
for $dot2 in $dot1/BOOK returnfor $dot2 in $dot1/BOOK return
$dot2/AUTHOR$dot2/AUTHOR
==
for $dot2 in (for $dot2 in (
ffor $dot1 in $root/BOOKS returnor $dot1 in $root/BOOKS return
$dot1/BOOK$dot1/BOOK
) return) return $dot2/AUTHOR$dot2/AUTHOR
29
Xquery: "Core language"Xquery: "Core language"
//BOOKS/BOOKBOOKS/BOOK[@YEAR < 2000[@YEAR < 2000]/TITLE]/TITLE
==
for $book in /BOOKS/BOOK returnfor $book in /BOOKS/BOOK return
ifif (not(empty( (not(empty(
for $year in $book/@YEAR returnsfor $year in $book/@YEAR returns
if $year < 2000 then $year else ()if $year < 2000 then $year else ()
))))
) ) thenthen
$book/TITLE$book/TITLE
elseelse
()()
Abbildung von Abbildung von OberflächensyntaxOberflächensyntaxauf "core language"auf "core language"
30
Teil 3Teil 3 XML und Information XML und Information
RetrievalRetrievalT. SchliederT. Schlieder
31
GliederungGliederung
• Einbeziehung der Dokument-StrukturEinbeziehung der Dokument-Struktur
• XML-Anfragesprachen und IRXML-Anfragesprachen und IR– ProblemeProbleme– Lösungsansatz mit Regular Path ExpressionsLösungsansatz mit Regular Path Expressions– Lösungsansatz mit User InterfaceLösungsansatz mit User Interface
• Der ApproXQL-AnsatzDer ApproXQL-Ansatz– DatenmodellDatenmodell– AnfragespracheAnfragesprache– Ähnliche StrukturenÄhnliche Strukturen– Vages EnthaltenseinVages Enthaltensein
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
32
Grundprinzip des IRGrundprinzip des IR
• Grundprinzip des IR: Grundprinzip des IR: – Es gibt ein InformationsbedürfnisEs gibt ein Informationsbedürfnis– Gesucht sind Dokumente, die Gesucht sind Dokumente, die
Informationsbedürfnis befiedigenInformationsbedürfnis befiedigen
• MerkmaleMerkmale– vage Dokumentrepräsentation vage Dokumentrepräsentation
(Vergabe von Deskriptoren)(Vergabe von Deskriptoren)– vage Queryformulierung vage Queryformulierung
(Abbildung Informationsbedürfnis auf (Abbildung Informationsbedürfnis auf Keywords)Keywords)
– vage Abbildung von Query auf Dokument-vage Abbildung von Query auf Dokument-RepräsentationRepräsentation
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
33
Was ändert sich durch Was ändert sich durch Struktur?Struktur?
• StrukturStruktur– in den Dokumentenin den Dokumenten– in den Anfragenin den Anfragen
kann helfen, die kann helfen, die PräzisionPräzision der Anfragen zu der Anfragen zu erhöhen.erhöhen.
• Interpretation der StrukturInterpretation der Struktur– vagevage in Dokumenten, Query und Abbildung in Dokumenten, Query und Abbildung
– strengstreng in Dokumenten, Query und Abbildung in Dokumenten, Query und Abbildung
– strengstreng in Dokumenten, in Dokumenten, vagevage in Query und in Query und AbbildungAbbildung
-> unrealistisch, da Struktur in Dokumenten vorgegeben-> unrealistisch, da Struktur in Dokumenten vorgegeben
-> XML-Anfragesprachen, IR-Systeme für strukt. Dok.-> XML-Anfragesprachen, IR-Systeme für strukt. Dok.
-> Relevanz-Ranking schwierig (?)-> Relevanz-Ranking schwierig (?)
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
34
Vage Struktur-InterpretationVage Struktur-Interpretation
• Probleme mit dem Begriff "Relevance Probleme mit dem Begriff "Relevance Ranking"Ranking"– Dokument-Struktur vorgegeben (nicht vage)Dokument-Struktur vorgegeben (nicht vage)– Dokument-Struktur muß (teilweise) bekannt Dokument-Struktur muß (teilweise) bekannt
sein, um Anfrage zu formulierensein, um Anfrage zu formulieren
• KompromißKompromiß– Relevanzbewertung für den 'Inhaltsteil' von Relevanzbewertung für den 'Inhaltsteil' von
Anfragen und DokumentenAnfragen und Dokumenten– Ähnlichkeitsmaß für StrukturÄhnlichkeitsmaß für Struktur
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
35
XML-Anfragesprachen und XML-Anfragesprachen und IRIR
• Mächtigkeit von XML-Anfragesprachen Mächtigkeit von XML-Anfragesprachen höher als für IR nötighöher als für IR nötig– Formulieren von Anfrage schwierig und Formulieren von Anfrage schwierig und
aufwendigaufwendig– Kann durch Nutzer-Interfaces kompensiert Kann durch Nutzer-Interfaces kompensiert
werdenwerden
• Nutzer muß Dokumenten-Struktur kennenNutzer muß Dokumenten-Struktur kennen
• Restriktive Interpretation von Struktur und Restriktive Interpretation von Struktur und DatenDaten
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
36
Regular Path ExpressionsRegular Path Expressions
• Regular Path Expressions wurden Regular Path Expressions wurden eingeführt umeingeführt um
• mit struktureller Heterogenität mit struktureller Heterogenität umzugehenumzugehen
• Anfragen mit partieller Kenntnis der Anfragen mit partieller Kenntnis der Struktur zu erlaubenStruktur zu erlauben
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
37
Regular Path ExpressionsRegular Path Expressions
"Ich möchte alle Bücher, "Ich möchte alle Bücher, die von Smith geschrieben die von Smith geschrieben worden sind."worden sind."
<<bookbook>> <<authorauthor>Smith</>Smith</authorauthor>> ......</</bookbook>>
<<bookbook>> <<editoreditor>Smith</>Smith</editoreditor>> ......</</bookbook>>
<<bookbook>> <<chapterchapter>> < <authorauthor>Smith</>Smith</authorauthor>> ...... </</chapterchapter>></</bookbook>>
<<bookbook>> <<chapterchapter>> < <texttext> ... Smith ... </> ... Smith ... </texttext> > </ </chapterchapter>> ......</</bookbook>>
Query 1Query 1 //bookbook//authorauthor="Smith"="Smith"
Query 2Query 2 //bookbook/(/(author author || editor editor)) [. [. ="Smith"]="Smith"]
Query 3Query 3 //bookbook//(//(author author || editor editor)) [. [. ="Smith"]="Smith"]
Query 4Query 4 //bookbook//[.="Smith"]//[.="Smith"]
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
38
Probleme:Probleme:
• Regular Path Expressions erfordernRegular Path Expressions erfordern– umfangreiche Kenntnis von Struktur und Inhalt umfangreiche Kenntnis von Struktur und Inhalt
der Dokumenteder Dokumente– Vertrautheit mit der Sprache (-Vertrautheit mit der Sprache (-
>Gelegenheitsnutzer)>Gelegenheitsnutzer)
• Alle Ergebnisse einer Query Alle Ergebnisse einer Query (mit Regular (mit Regular
Path Expressions)Path Expressions) werden gleich bewertet werden gleich bewertet (mit 'true')(mit 'true')
Regular Path ExpressionsRegular Path Expressions
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
39
• User Interfaces machen den Nutzer User Interfaces machen den Nutzer mit der Dokumentenstruktur bekanntmit der Dokumentenstruktur bekannt
• Probleme:Probleme:– Anzeige der Anzeige der gesamten Strukturgesamten Struktur
führt zu "Information Overload" führt zu "Information Overload" Verringerung der Verringerung der Nutzerakzeptanz Nutzerakzeptanz
– Top-Down-NavigationTop-Down-Navigation führt evtl. führt evtl. zu Verlust von relevanten zu Verlust von relevanten Ergebnissen.Ergebnissen.
XML-Anfragesprachen und User XML-Anfragesprachen und User InterfacesInterfaces
bookbook
authorauthor
namename
editoreditor
chapterchapter++
++
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
40
LösungsansatzLösungsansatz
• Vereinfachtes DatenmodellVereinfachtes Datenmodell
• Einfache strukturierte AnfragenEinfache strukturierte Anfragen
• Unterstützung durch User InterfaceUnterstützung durch User Interface
• Klassische IR-Methoden für Dokument-Klassische IR-Methoden für Dokument-InhaltInhalt
• Ähnlichkeitsbewertung der StrukturÄhnlichkeitsbewertung der Struktur
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
41
DatenmodellDatenmodell
<<bookbook year year="1999"="1999">> <<authorauthor id id="a1"="a1">> <<namename>John >John BradleyBradley</</namename>> </</authorauthor>> ...... <<chapterchapter ref ref="a1"="a1">> <<authorauthor>>SmithSmith</</authorauthor>> <<sectionsection>> <<titletitle>>XMLXML</</titletitle>> ... ... </</sectionsection>> ...... </</chapterchapter>> ......</</bookbook>>
book
chapter
section
title
XML
author
name
John Bradley
author
Smith
{ year = "1999" }
PCDATA PCDATA
PCDATA
42
NormalisierungNormalisierung
book
chapter
section
title
XML
author
name
John Bradley
author
Smith
{ year = "1999" }
PCDATA PCDATA
PCDATA
• Entferne Entferne LinksLinks• Normalisiere AttributeNormalisiere Attribute
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
43
NormalisierungNormalisierung
book
chapter
section
title
XML
author
name
John Bradley
author
Smith
PCDATA PCDATA
PCDATA
year
1999
• Normalisiere PCDATANormalisiere PCDATA
• Entferne Entferne LinksLinks• Normalisiere AttributeNormalisiere Attribute
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
44
NormalisierungNormalisierung
book
chapter
section
title
author
name author
year
1999
XML
Smith
Bradley
John
• Füge neue Wurzel hinzuFüge neue Wurzel hinzu
• Normalisiere PCDATANormalisiere PCDATA
• Entferne Entferne LinksLinks• Normalisiere AttributeNormalisiere Attribute
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
45
NormalisierungNormalisierung
book
chapter
section
title
author
name author
year
1999
XML
Smith
Bradley
John
book
root
• Füge neue Wurzel hinzuFüge neue Wurzel hinzu
• Normalisiere PCDATANormalisiere PCDATA
• Entferne Entferne LinksLinks• Normalisiere AttributeNormalisiere Attribute
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
46
"Database""Database"
Anfragesprache (graph. Anfragesprache (graph. Interpretation)Interpretation)
• Eine Query ist ein gelabelter BaumEine Query ist ein gelabelter Baum• Kinder eines Knotens werden durch log. Kinder eines Knotens werden durch log.
Ausdruck verbundenAusdruck verbunden
bookbook
authauthoror
chapterchapter
"Smit"Smith"h"
titletitle
"XML""XML"
logischer Ausdrucklogischer Ausdruck
logischer Ausdrucklogischer Ausdruck
z.B. - Boolesche Logikz.B. - Boolesche Logik- Gewichtete - Gewichtete
SummeSumme
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
47
Was sind ähnliche Was sind ähnliche Strukturen?Strukturen?
articlearticle
authorauthor
bookbook
editoreditorähnlich?ähnlich?
bookbook
authorauthor
bookbook
chapterchapterähnlich?ähnlich?
authorauthor
QueryQuery DokumentDokument
bookbook
chapterchapter
bookbookähnlich?ähnlich?
authauthoror
authorauthor
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
48
Was sind ähnliche Was sind ähnliche Strukturen?Strukturen?
bookbook
authorauthor
bookbook
authorauthorähnlich?ähnlich?
authorauthor
bookbook
bookbook
authorauthorähnlich?ähnlich?
QueryQuery DokumentDokument
titletitleANDAND
bookbook
authorauthor
bookbookähnlich?ähnlich?
xx
yy
authauthoror
LinkLink
Verwandschaft zur Bio-Informatik Verwandschaft zur Bio-Informatik (Tree Edit Distance, Tree Alignment)(Tree Edit Distance, Tree Alignment)
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
49
Sinnvolle Sinnvolle ÄhnlichkeitsoperatorenÄhnlichkeitsoperatoren
articlearticle
authorauthor
bookbook
editoreditor
QueryQuery DokumentDokument
1. 1. Umbenennen von KnotennamenUmbenennen von Knotennamen (Element-, Attributnamen)(Element-, Attributnamen)
mit Hilfe von Kostenfunktionmit Hilfe von Kostenfunktion
Ähnlichkeit der NamenÄhnlichkeit der Namen• von Administrator festgelegt (DTD-Analyse)von Administrator festgelegt (DTD-Analyse)• gelernt (z.B. via Data-Mining)gelernt (z.B. via Data-Mining)
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
50
Sinnvolle Sinnvolle ÄhnlichkeitsoperatorenÄhnlichkeitsoperatoren
bookbook
authorauthor
bookbook
chapterchapter
QueryQuery DokumentDokument
2. 2. Überspringen von Datenknoten Überspringen von Datenknoten mit Hilfe von Kostenfunktionmit Hilfe von Kostenfunktion
Kosten der KnotenKosten der Knoten• von Administrator festgelegt (DTD-Analyse)von Administrator festgelegt (DTD-Analyse)• gelernt (z.B. via Data-Mining)gelernt (z.B. via Data-Mining)
authorauthor
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
51
Sinnvolle Sinnvolle ÄhnlichkeitsoperatorenÄhnlichkeitsoperatoren
bookbook
authorauthor
bookbook
QueryQuery DokumentDokument
3. 3. Löschen von Query-KnotenLöschen von Query-Knotenin in semantisch sinnvollersemantisch sinnvoller weise. weise.
vages Enthaltenseinvages Enthaltensein
authorauthorchapterchapter
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
52
"Smith""Smith"
authorauthor
bookbook
chapterchaptertitletitle"XML""XML"
"Database""Database"
DokumentDokument
EnthaltenseinEnthaltensein
"Database""Database"
bookbook
authauthoror
chapterchapter
"Smit"Smith"h"
titletitle
"XML""XML"
QueryQuerylogischer Ausdruck 1logischer Ausdruck 1
logischer Ausdruck 2logischer Ausdruck 2
logischer Ausdruck 2logischer Ausdruck 2
logischer Ausdruck 1logischer Ausdruck 1
Annahme 1:Annahme 1:• Vater-Kind-KnotenVater-Kind-Knoten
modellierenmodellierenEnthaltenseinEnthaltensein
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
53
Vages EnthaltenseinVages Enthaltensein
authorauthor
"Smith""Smith"
bookbook
chapterchaptertitletitle"XML""XML"
"Database""Database"
DokumentDokument
Annahme 2:Annahme 2:• Nutzer Nutzer bevorzugtbevorzugt bestimmten Kontext bestimmten Kontext
Score :=Score :=ff(book["Smith","XML",Database"]) (book["Smith","XML",Database"])
ff(book/author["Smith"]) (book/author["Smith"]) ff(book/(book/
chapter["XML",Database"]) chapter["XML",Database"]) ff(book/chapter/titel["XML"])(book/chapter/titel["XML"])
gleichesgleicheschapterchapter
gleichesgleichesbookbook
Constraints:Constraints:
logischer Ausdruck 2logischer Ausdruck 2logischer Ausdruck 1logischer Ausdruck 1
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein
54
Zusammenfassung Teil 3Zusammenfassung Teil 3
• Dokumentstruktur erlaubt präzisere Dokumentstruktur erlaubt präzisere AnfragenAnfragen
• Nutzer muß Struktur partiell kennenNutzer muß Struktur partiell kennen
• Dokumentstruktur sollte vage interpretiert Dokumentstruktur sollte vage interpretiert werden (best matches first)werden (best matches first)
• Nicht alle strukturellen Ähnlichkeitsmaße Nicht alle strukturellen Ähnlichkeitsmaße sinnvollsinnvoll– SemantikSemantik– BerechnungskomplexitätBerechnungskomplexität
Querying XML Motivation Einsatzgebiete SQL/OQL Anfragesprachen Hauptbestandteile Pfadausdrücke Sortieren Quantoren Subqueries QuellenKomb. Bewertung
XML und IR Struktur IR und QL für XML Path Expressions User Interfaces ApproXQL-Ansatz Datenmodell Anfragesprache Ähnlichkeit Enthaltensein