+ All Categories
Transcript
Page 1: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

Topic Maps Query Language

Sven Krosse M. Sc.

Topic Maps Lab an der Universität Leipzig

[email protected]

Session 3

Page 2: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

Review – Session 1 and 2

1. Meta-Modell von TMQL

2. Grammatik

3. Navigationskonzept

4. Path-Language – Draft 2010 ( kurzer Einblick )

Page 3: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

Agenda

1. Postfix

● Filter

– Boolean-Expression

– Filtertypen

● Projektion

2. Operatoren

Page 4: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

SprachbestandteilePostfix

Page 5: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

Postfix

● als Ergänzung für Path-Expression ( Simple-Content )

● erlauben exakte Definition der Ergebnismenge in Path-

Expressions

● Typen

● Filter

● Projektion

Page 6: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

SprachbestandteileFilter

Page 7: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de7

Filter

● Filter nur nach kompletter Navigation

● Filter nach jedem Schritt als Erweiterung einiger TMQL

Engines

● CL-Filter

● immer Boolean-Expression

● Syntax: [ boolean-expression ]

● NCL-Filter

● zur vereinfachten Verwendung

● Syntax ist variabel

Page 8: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de8

Boolean-Expression

● quantitativ oder nicht-quantitativ

● Unterstützung von boolean'schen Operatoren

● Konjunktion mit AND

● Disjunktion mit OR

● Negation mit NOT

Page 9: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de9

Quantitative Boolean-Expression

● numerisch strikte Bedingung

● Anzahl der erfüllenden Tuple

● untere Grenze spezifiziert

AT LEAST number binding-set SATISFIES boolean-expression

● obere Grenze spezifiziert

AT MOST number binding-set SATISFIES boolean-expression

● Abhängigkeit von Variablen durch Binding-Set definiert

Page 10: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de10

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Page 11: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de11

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Filterdefinition

Page 12: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de12

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Numerische Quantifizierung

Page 13: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de13

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Variable-Binding

Page 14: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de14

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Bedingung

Page 15: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de15

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

AT MOST 3

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

→ alle Komponisten, welche maximal 3 Opern komponiert

haben

Page 16: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de16

Quantitative Boolean-Expression

● numerisch freie Bedingung

● exakte Anzahl der erfüllenden Tuple irrelevant

● unteres Minimum

SOME binding-set SATISFIES boolean-expression

● oberes Maximum

EVERY binding-set SATISFIES boolean-expression

Page 17: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de17

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

SOME

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

Page 18: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de18

Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

SOME

$opera IN // o:opera

SATISFIES $opera >> traverse o:composed-by == .

]

→ alle Komponisten, welche mindestens eine Oper

komponiert haben

Page 19: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de19

Nicht-Quantitative Boolean-Expression

● Bedingung nicht an numerische Grenzen gebunden

● reine Existenz entscheidend

● Syntax: EXISTS boolean-expression

● Schlüsselwort EXISTS optional

● NCL-Vertreter

● Typ-Instanz-Beziehung ( ISA-Expression )

● Supertyp-Subtyp-Beziehung ( AKO-Expression )

Page 20: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de20

Nicht-Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

. ISA o:musician

]

Page 21: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de21

Nicht-Quantitative Boolean-Expression

%prefix o http://psi.ontopia.net/music/

// o:composer

[

. ISA o:musician

]

→ alle Komponisten, welche auch Instanz von Musiker sind

Page 22: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de22

NCL-Filter

● spezielle Filter auf dem NCL

● Index-Filter

● Range-Filter

● Scope-Filter

● Typ-Filter

● besitzen eine Entsprechung auf CL

Page 23: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de23

NCL-Filter – Index-Filter

● spezielles Tuple aus der Ergebnissequenz

● Null-basierter Index

● leere Menge wenn Index außerhalb des möglichen Bereichs

● Syntax:

[ number ] → [ $# == number ]

● Bsp:

// http://psi.ontopia.net/music/composer / tm:name [ 0 ]

Page 24: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de24

NCL-Filter – Range-Filter

● spezieller Bereich aus der Ergebnissequenz

● Null-basierte Indizes

● alle Elemente die vom Index-Bereich abgedeckt werden

● Syntax

[ a .. b ] → [ a <= $# AND $# < b ]

● Bsp:

// http://psi.ontopia.net/music/composer / tm:name [ 0 .. 1 ]

Page 25: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de25

NCL-Filter – Scope-Filter

● Filterung nach Themes

@ theme → [ . >> scope == theme ]

[ @ theme ] → [ . >> scope == theme ]

● Bsp:

// http://psi.ontopia.net/music/composer / tm:name

@http://psi.ontopia.net/basename/short-name

oder

// http://psi.ontopia.net/music/composer / tm:name

[ @http://psi.ontopia.net/basename/short-name ]

Page 26: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de26

NCL-Filter – Type-Filter

● Filterung nach Typ

[ ^ type ] → [ . >> types == type ]

// type → [ . >> types == type ]

● Bsp:

%prefix o http://psi.ontopia.net/music/

// o:composer >> traverse [ ^ o:opera ]

oder

// o:composer >> traverse // o:opera

Page 27: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de27

Vergleich Draft 2010

● Draft 2010

● Filterung nach jedem Navigationsschritt möglich

● Kombination von Filtern

● keine Projektion

Page 28: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de28

Vergleich Draft 2010

● Beispiel: Filter Draft 2010

/ composer [ . / firstname / value:: =~ „.*Puccini.*“ ] / role::

/ composer / webpage @web @italian / value::

Page 29: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

SprachbestandteileProjektion

Page 30: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de30

Projektion

● Alternative zu Filtern

● Erzeugung von Tupeln mit mehren Elementen

● Ausgangspunkt ist aktueller Knoten im Graph als Ergebnis der

Navigation

● Beschreibung als Tuple-Expression

● optionale Sortierung definierbar

● Syntax: tuple-expression ::= ( <value-expression> )

value-expression ::= content { ASC | DESC }

Page 31: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de31

Projektion

%prefix o http://psi.ontopia.net/music/

// o:composer

(

. ,

. / tm:name ,

. / tm:occurrence,

. >> indicators

)

Page 32: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de32

Projektion

%prefix o http://psi.ontopia.net/music/

// o:composer

(

. ,

. / tm:name ,

. / tm:occurrence,

. >> indicators

)

Projektionsdefinition

Page 33: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de33

Projektion

%prefix o http://psi.ontopia.net/music/

// o:composer

(

. ,

. / tm:name ,

. / tm:occurrence,

. >> indicators

)

aktueller Knoten

Page 34: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de34

Projektion

%prefix o http://psi.ontopia.net/music/

// o:composer

(

. ,

. / tm:name ,

. / tm:occurrence,

. >> indicators

)

Projektionstupel

Page 35: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

SprachbestandteileOperatoren

Page 36: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de36

Operatoren

● erlaubt in so genannte Value-Expression oder Content

● z.B.: Bestandteil einer Boolean-Expression

● verschiedene Typen

● mathematische Operatoren

● Vergleichsoperatoren

● Mengenoperatoren

Page 37: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de37

mathematische Operatoren

● Vorzeichen '-'

● unterstützte Datentypen:

– Number

Page 38: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de38

mathematische Operatoren

● Addition '+'

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Page 39: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de39

mathematische Operatoren

● Subtraktion '-'

● unterstützte Datentypen:

– Number

– Date

– Time

– DateTime

Page 40: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de40

mathematische Operatoren

● Multiplikation '*'

● unterstützte Datentypen:

– Number

Page 41: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de41

mathematische Operatoren

● Division '%'

● unterstützte Datentypen:

– Number

Hinweis: im Draft 2010 ersetzt durch 'div'

Page 42: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de42

mathematische Operatoren

● Modulo 'mod'

● unterstützte Datentypen:

– Number

Page 43: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de43

Vergleichsoperatoren

● kleiner-als '<'

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Page 44: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de44

Vergleichsoperatoren

● kleiner-oder-gleich '<='

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Page 45: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de45

Vergleichsoperatoren

● größer-als '>'

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Page 46: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de46

Vergleichsoperatoren

● größer-oder-gleich '>='

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Page 47: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de47

Vergleichsoperatoren

● reguläre Ausdrücke '=~'

● unterstützte Datentypen:

– String

Page 48: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de48

Vergleichsoperatoren

● Gleichheit '=='

● unterstützte Datentypen:

– Number

– String

– Date

– Time

– DateTime

Hinweis: im Draft 2010 ersetzt durch '='

Page 49: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de49

Mengenoperatoren

● Vereinigung '++'

● Kombination beider Mengen als neue Sequenz

● Beispiel:

{[A, C], [E, F]} ++ { [C, D]} → {[A, C], [E, F], [C, D]}

Hinweis: im Draft 2010 ersetzt durch 'union'

Page 50: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de50

Mengenoperatoren

● Differenz '--'

● entfernt die Elemente der ersten Menge, welche auch in der

zweiten enthalten sind

● Beispiel:

{[A, C], [C, D]} -- { [C, D]} → {[A, C]}

Hinweis: im Draft 2010 ersetzt durch 'minus'

Page 51: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de51

Mengenoperatoren

● Schnittmenge '=='

● liefert die Schnittmenge beider Mengen

● Beispiel:

{[A, C], [C, D]} == { [C, D]} → {[C, D]}

Hinweis: im Draft 2010 ersetzt durch 'intersect'

Page 52: TMQL tutorial - part 3

Einführung in Topic Maps

topicmapslab.de

ENDE


Top Related