Top Banner
Introduction to Topic Maps topicmapslab.de Topic Maps Query Language Sven Krusty M. Sc. Topic Maps Lab at the University of Leipzig [email protected] Session 1
328

Tmql tutorials (english)

Jan 28, 2018

Download

Technology

Chris Barnett
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic Maps Query Language

Sven Krusty M. Sc.

Topic Maps Lab at the University of Leipzig

[email protected]

Session 1

Page 2: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Agenda

1. Basics

● TMQL metamodel

- Compared to TMDM● Grammar

2. TMQL as language

● Topic identification● Navigation concept

Page 3: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

BasicsMetamodel

Page 4: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Metamodel

● represented as a topic map

● each topic can be used in the query

● Topic Maps represent different elements in TMDM

Page 5: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM

Page 6: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMQL

● Topic Map construct does not exist● no reification of topic maps possible● Query all topics difficult or Association

Page 7: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM

Page 8: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM → TMQL

Page 9: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMQL

● No distinction between name and Occurrence

→ Characteristics

Page 10: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM

Page 11: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM → TMQL

Page 12: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMQL

● no direct support of variants

→ Query only special feature

Page 13: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM

Page 14: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMDM → TMQL

Page 15: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMQL

● no role constructs

→ no reification of roles

Page 16: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Summary

● No distinction between name andOccurrences

● No variations of name

● no role constructs

● A topic map construct

Page 17: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

BasicsGrammar

Page 18: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Grammar

● defined in three levels

● each level was inspired by other standards

Page 19: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de19

Token Level

● Terminal symbols of the language

● Definition based on regular expressions

Token Level

Page 20: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de20

Canonical Level

● Definition of production rules

Example: tuple-expression: = <value-expression>

Token Level

Canonical Level

Page 21: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de21

Non-Canonical Level

Token Level

Canonical Level

Non-Canonical Level

● Term substitution as new production rules

● Definition of shorter terms

anchor / tm: name ==> anchor>> chracteristics tm: name

Page 22: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofLiterals and constants

Page 23: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Literals and constants

● Constants (atoms) are data types and operators

● Acquisition of CTM data types

Page 24: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Literals and constantsAtom possible valueAtom Undefined | boolean | number | date | datetime | string | iri

undefined undef

boolean true or false

number decimal or integer

decimal /[+-]?/ +(/./ D d +)? /

integer /[+-]?/ D + /

date '-'? yyyy '-' mm '-' dd (zzzzzz)?

DateTime '-'? yyyy '-' mm '-' dd 'T' hh ':' mm ':' ss ('.' s +)? (Zzzzzz)?

iri see RFC 3987

string /"([^"]|/")*"/ | /'([^']|/')*'/

Page 25: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofTopic identification

Page 26: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic identification

● Use of references or string literals

● String literals translated by axes

● References are automatically translated

● Subject identifier● Subject Locator● Item Identifier

Page 27: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic identification

● item-identifier

puccini

● subject-identifier

http://en.wikipedia.org/wiki/Puccini

● subject-locator

http://en.wikipedia.org/wiki/Puccini

Page 28: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic identification

● Item identifier

"Puccini" <<item

● Subject-identifier

"Http://en.wikipedia.org/wiki/Puccini"<<Indicators

● Subject locator

"Http://en.wikipedia.org/wiki/Puccini"<<Locators

Page 29: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofNavigation concept

Page 30: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de30

Navigation concept

● based on the proxy concept of TMRM

● Model of the topic map as an abstract bi-directional graph

● Definition of 12 axes (+2 NCL)

Page 31: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de31

Navigation concept - Syntax

DIRECTION:: = '<<' | '>>'

AXIS-NAME:: = 'item' | 'indicators' | 'locators' | 'traverse' |'Players' | 'roles' | 'types' | 'reifier' | 'atomify' |'Characteristics' | 'super types' | 'scope'

STEP:: = DIRECTION AXIS-NAME [TOPIC-REF]

Page 32: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de32

Axis - indicators

● no optional types

● Next: All Subject identifier of a topic

● Prev: addressing a topic with subject identifier

Page 33: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de33

Axis - indicators

http://en.wikipedia.org/wiki/Puccini>> indicators

"Http://en.wikipedia.org/wiki/Puccini" <<indicators

Page 34: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de34

Axis - locators

● no optional types

● Next: All Subject locator of a topic

● Prev: addressing a topic with subject Locator

Page 35: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de35

Axis - locators

http://en.wikipedia.org/wiki/Puccini>> locators

"Http://en.wikipedia.org/wiki/Puccini" <<locators

Page 36: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de36

Axis - item

● no optional types

● without pluralization!

Items →

● Next: all item identifier of a topic

● Prev: Addressing a topic of Item Identifier

Page 37: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de37

Axis - item

http://en.wikipedia.org/wiki/Puccini>> item

"Http://en.wikipedia.org/wiki/Puccini" <<item

Page 38: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de38

Axis - types

● no optional types

● Next: all types of a topic or the type of topic mapsConstruct

● Prev: all instances of a type Topic

● NCL: instances - Axis

● Next: all instances of a topic type● Prev: all types of topics or the type of Topic

Maps construct

Page 39: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de39

Axis - types

http://en.wikipedia.org/wiki/Puccini>> types

http://psi.ontopia.net/music/composer <<types

http://en.wikipedia.org/wiki/Puccini <<instances

http://psi.ontopia.net/music/composer>> instances

Page 40: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de40

Axis - super types

● no optional types

● forward: all the super types of a type Topic

● Prev: all sub-types of a type Topic

● NCL: subtypes - Axis

● Next: all sub-types of a type Topic● Prev: all super types of a type Topic

Page 41: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de41

Axis - super types

http://psi.ontopia.net/music/composer>> super types

http://psi.ontopia.net/music/musician <<super types

http://psi.ontopia.net/music/composer <<subtypes

http://psi.ontopia.net/music/musician>> subtypes

Page 42: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de42

TMQL - Type Hierarchy

e1

A

B CD

E F G

e2 g1 g2

Page 43: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de43

e1

A

B CD

E F G

e2 g1

TMQL - Type Hierarchy

e1>> types

Page 44: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de44

e1

A

B C

E F

e2 g1 g2

TMQL - Type Hierarchy

E>> super types

Page 45: Tmql tutorials (english)

45

e1

A

B CD

F G

g1 g2

TMQL - Type Hierarchy

TMQL Query: A>> instances

Page 46: Tmql tutorials (english)

Introduction to Topic Maps

46

Axis - characteristics

● forward: all the features of a topic

● Prev: the topic with the property

● predefined types

● all name● All Occurrences

Page 47: Tmql tutorials (english)

topicmapslab.de47

>> Characteristics

http://en.wikipedia.org/wiki/Puccini>> Characteristics tm: occurrence

Page 48: Tmql tutorials (english)

topicmapslab.de

e1

Name 1 t

g

Occurrence 1 t

g

Page 49: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

e1

Name 1 t

g

Occurrence 1

Occurrence 2

t

g

TMQL - characteristics axis

TMQL Query: e1>> characteristics g

Page 50: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

END

Page 51: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic Maps Query Language

Sven Krusty M. Sc.

Topic Maps Lab at the University of Leipzig

[email protected]

Session 2

Page 52: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Agenda

1. Navigation Concept II

2. Path Language - Draft 2010 (short view)

Page 53: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofNavigation concept

Page 54: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de4

Navigation concept

● based on the proxy concept of TMRM

● Definition of 12 axes (+2 NCL)

Page 55: Tmql tutorials (english)

topicmapslab.de5

DIRECTION:: = '<<' | '>>'

AXIS-NAME:: = 'item' | 'indicators' | 'locators' | 'traverse' |

'Characteristics' | 'super types' | 'scope'

STEP:: = DIRECTION AXIS-NAME [TOPIC-REF]

Page 56: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Axis - indicators

● Next: All Subject identifier of a topic

Page 57: Tmql tutorials (english)

7

Axis - indicators

http://en.wikipedia.org/wiki/Puccini>> indicators

Page 58: Tmql tutorials (english)

topicmapslab.de

Page 59: Tmql tutorials (english)

topicmapslab.de

Page 60: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de10

no optional types

Items →

Next: all item identifier of a topic

Page 61: Tmql tutorials (english)

Introduction to Topic Maps

11

Axis - item

Page 62: Tmql tutorials (english)

topicmapslab.de

● no optional types

Construct

Next: all instances of a topic type● Prev: all types of topics or the type of Topic

Page 63: Tmql tutorials (english)

Introduction to Topic Maps

13

http://en.wikipedia.org/wiki/Puccini <<instances

http://psi.ontopia.net/music/composer>> instances

Page 64: Tmql tutorials (english)

topicmapslab.de

no optional types

forward: all the super types of a type Topic

-

Page 65: Tmql tutorials (english)

http://psi.ontopia.net/music/musician <<super types

Page 66: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de16

e1

A

B CD

E F G

e2 g1 g2

Page 67: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de17

e1

A

B CD

E F G

e2 g1 g2

TMQL - Type Hierarchy

e1>> types

Page 68: Tmql tutorials (english)

topicmapslab.de

A

B

F G

g2

TMQL Query:

Page 69: Tmql tutorials (english)

topicmapslab.de

e1

C

G

Page 70: Tmql tutorials (english)

forward: all the features of a topic

all name● All Occurrences

Page 71: Tmql tutorials (english)

topicmapslab.de

Axis - characteristics

http://en.wikipedia.org/wiki/Puccini>> Characteristics tm: name

Page 72: Tmql tutorials (english)
Page 73: Tmql tutorials (english)

Introduction to Topic Maps

Name 2

t

e1>> characteristics g

Page 74: Tmql tutorials (english)

Introduction to Topic Maps

Next: Literal of the specific object

Page 75: Tmql tutorials (english)

http://en.wikipedia.org/wiki/Puccini>> Characteristics>> atomify

Page 76: Tmql tutorials (english)

topicmapslab.de26

Axis - players

● Next: all players an association

● by an association of type Topic● optional type = Role Type

● Prev: all association with the player

● optional type = Role Type

Page 77: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de27

Axis - players

http://en.wikipedia.org/wiki/Puccini <<players

http://psi.ontopia.net/music/composed-by>> players

Page 78: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Axis - roles

● Next: all types of roles an association

optional type = type of association

Page 79: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de29

http://psi.ontopia.net/music/composed-by>> roles

Page 80: Tmql tutorials (english)

30

● Concatenation of an association between two topics

Page 81: Tmql tutorials (english)

topicmapslab.de31

Page 82: Tmql tutorials (english)

Introduction to Topic Maps

32

p1 p3p2

r2

Page 83: Tmql tutorials (english)

TMQL - association axes

p2 <<play>> roles [. >> Players == p2]

r1 a1

p2

Page 84: Tmql tutorials (english)

r3

Page 85: Tmql tutorials (english)

35

p1

Page 86: Tmql tutorials (english)
Page 87: Tmql tutorials (english)

http://psi.ontopia.net/music/composed-by>> scope

Page 88: Tmql tutorials (english)

Axis - reifier

● no optional type

Next: the construct of Reifier

● Prev: the reified element

Page 89: Tmql tutorials (english)

topicmapslab.de

Axis - reifier

http://psi.ontopia.net/music/composed-by>> reifier

Page 90: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofDraft 2010

Page 91: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de41

Draft 2010

● only path expression

● Changes

● navigation similar concept with a modified syntax●

● additional axes● Removal of some axes

Syntax closer to XPath

Standard axles for each construct type (axes optional)

Page 92: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de42

pathspec → axis '::' anyref | axis '::' | anyref | assocpattern

filter → boolfilter | scope filter

Page 93: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

type, direct-type, instance, direct-instance

Page 94: Tmql tutorials (english)
Page 95: Tmql tutorials (english)
Page 96: Tmql tutorials (english)
Page 97: Tmql tutorials (english)
Page 98: Tmql tutorials (english)
Page 99: Tmql tutorials (english)
Page 100: Tmql tutorials (english)
Page 101: Tmql tutorials (english)
Page 102: Tmql tutorials (english)

topicmapslab.de

- Boolean expression- Filter types

● Projection

2. Operators

Page 103: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofPostfix

Page 104: Tmql tutorials (english)

Introduction to Topic Maps

Postfix

as a supplement for Path Expression (simple content)

● allow precise definition of the result set in PathExpressions

● Types

● Filter● Projection

Page 105: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofFilter

Page 106: Tmql tutorials (english)

Introduction to Topic Maps

7

Filter

Page 107: Tmql tutorials (english)

topicmapslab.de

NOT

Page 108: Tmql tutorials (english)

● Number of satisfying tuples

Page 109: Tmql tutorials (english)
Page 110: Tmql tutorials (english)
Page 111: Tmql tutorials (english)
Page 112: Tmql tutorials (english)

At most 3$ Opera IN / / o: opera

]

Page 113: Tmql tutorials (english)

/ / O: composer

$ Opera IN / / o: operaSatisfies $ opera>> traverse o: composed-by ==.

]

Condition

Page 114: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de15

Quantitative Boolean expression

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

/ / O: composer

[

At most 3$ Opera IN / / o: operaSatisfies $ opera>> traverse o: composed-by ==.

]

→ all the composers who composed more than 3 operahave

Page 115: Tmql tutorials (english)

topicmapslab.de16

Quantitative Boolean expression

numerically-free condition

● exact number of satisfying tuples irrelevant

● Maximum upper

EVERY binding-set satisfies boolean-expression

Page 116: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de17

/ / O: composer

Page 117: Tmql tutorials (english)

topicmapslab.de

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

]

all composers, which at least one opera

Page 118: Tmql tutorials (english)
Page 119: Tmql tutorials (english)
Page 120: Tmql tutorials (english)
Page 121: Tmql tutorials (english)
Page 122: Tmql tutorials (english)

NCL-Filter - Filter Index

● special tuple from the result sequence

● empty set if index is outside the possible range

● Syntax:

[Number] → [$ # == number]● Example:

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

Page 123: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de24

● Zero-based indexes

all items covered by the index range

● Syntax

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

Page 124: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

NCL-Filter - Filter Scope

Filtering by Themes

@ Theme → [. >> Scope == theme]

[@ Theme] → [. >> Scope == theme]

● Example:

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

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

Page 125: Tmql tutorials (english)

26

NCL-filter - Type filter

Filtering by Type

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

Page 126: Tmql tutorials (english)

Compare Draft 2010

Combination of filters

Page 127: Tmql tutorials (english)
Page 128: Tmql tutorials (english)
Page 129: Tmql tutorials (english)
Page 130: Tmql tutorials (english)
Page 131: Tmql tutorials (english)
Page 132: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de33

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

/ / O: composer

(

. ,

. / Tm: occurrence,

. >> Indicators

Page 133: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de34

Projection

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

/ / O: composer

(

. ,

. / Tm: name,

. / Tm: occurrence,

. >> Indicators)

Projektionstupel

Page 134: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofOperators

Page 135: Tmql tutorials (english)

Introduction to Topic Maps

36

● allowed in so-called value-expression or content

● eg part of a Boolean expression● different types

Mathematical Operators

Comparison operators●

Page 136: Tmql tutorials (english)
Page 137: Tmql tutorials (english)
Page 138: Tmql tutorials (english)
Page 139: Tmql tutorials (english)
Page 140: Tmql tutorials (english)
Page 141: Tmql tutorials (english)
Page 142: Tmql tutorials (english)

Introduction to Topic Maps

43

less-than "<"

Number- String-

-

-

Page 143: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de44

Comparison operators

● less than or equal '<='

● Supported data types:

- Number- String- Date- Time- DateTime

Page 144: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Comparison operators

greater-than '>'

Supported data types:

-

-

Time

Page 145: Tmql tutorials (english)

Comparison operators

DateTime

Page 146: Tmql tutorials (english)

regular expressions '= ~'

Page 147: Tmql tutorials (english)
Page 148: Tmql tutorials (english)
Page 149: Tmql tutorials (english)

NOTE: replaces the Draft 2010 by "minus"

Page 150: Tmql tutorials (english)

51

● Intersection of '=='

● returns the intersection of both sets● Example:

Note: Draft 2010 replaced by 'intersect'

Page 151: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

END

Page 152: Tmql tutorials (english)

topicmapslab . De

Topic Maps Lab at the University of Leipzig

[email protected]

Session 4

Page 153: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Review - Session 3

Postfix

● Filter

- Boolean expression- Filter types

Projection

Operators

Page 154: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

1. Features

● Draft 2007 Features

Page 155: Tmql tutorials (english)

topicmapslab.de

Page 156: Tmql tutorials (english)

Introduction to Topic Maps

5

Features

Page 157: Tmql tutorials (english)
Page 158: Tmql tutorials (english)
Page 159: Tmql tutorials (english)
Page 160: Tmql tutorials (english)
Page 161: Tmql tutorials (english)

● Description:

● returns the length of string literals

other constructs are converted to literal

Note Draft 2010: renamed 'string-length'

Page 162: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de11

Feature - length

● Example

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

→ all the names of Puccini with length 10

Page 163: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de12

Construct literal transformation

● Topic → Name, Subject, Identifier, Subject locator Item Identifier

● Name → string literal

● Occurrence → string literal

● Variant → string literal

● Role → Item Identifier

Association → Item Identifier

Page 164: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de13

Function - slice

● Description:

Page 165: Tmql tutorials (english)

topicmapslab.de

● Identifier:

Page 166: Tmql tutorials (english)
Page 167: Tmql tutorials (english)
Page 168: Tmql tutorials (english)
Page 169: Tmql tutorials (english)
Page 170: Tmql tutorials (english)

Functions TMQL4J

● Identifier:

● Arguments: a set and two numeric values

● Description:

Sub-set of strings defined by numerical values● numeric values define maximum range● Example: substring ("abc", 0, 9)

= {"Abc"}

Note Draft 2010: 3 Argument defines the set of characters

Page 171: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de20

Features - Draft 2010

● Identifier: starts-with

● Arguments: a set of literals and Vergleichsliteral

● Description:

Checking whether literal begins with Vergleichsliteral● Example: starts-with ({"ab", "bc"}, "a")

Page 172: Tmql tutorials (english)

Identifier: ends-with

Example:

=

Page 173: Tmql tutorials (english)

22

Page 174: Tmql tutorials (english)
Page 175: Tmql tutorials (english)

{"", "C"}

Page 176: Tmql tutorials (english)

topicmapslab.de

Features - Draft 2010

Identifier: normalize-space

● Arguments:

● Description:

● remove multiple occurrences of spaces● normalize-space ({"ab", "bc"})

= {"Ab", "bc"}

Page 177: Tmql tutorials (english)

26

Features - Draft 2010

● Identifier: translate

● Arguments: a set of literals, and two more literals

● Description:

replaces each character of the 2nd Literal characters by the 3rd

Example: translate ("Puccini", "PCI", "xyz")

= {"Xuyyznz"}

Page 178: Tmql tutorials (english)

● find

a set of literals and other literal

Example:

=

Page 179: Tmql tutorials (english)

extract-regexp

Description:

{"Pucc"}

Page 180: Tmql tutorials (english)
Page 181: Tmql tutorials (english)
Page 182: Tmql tutorials (english)

a lot of numeric literals

● round ({1.5, - 1.5, 5.1})

= {2, -1, 5}

Page 183: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de32

Identifier: TopicMap

Arguments: no

● Description:

● returns the instance of the Topic Map

Page 184: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de33

Features - Draft 2010

● Lite Ralf fonctions

● Transformation of construct to literals of theType

● Features

string● boolean● number

Page 185: Tmql tutorials (english)

END

Page 186: Tmql tutorials (english)

topicmapslab . De

Sven Krusty M. Sc.

[email protected]

Session 5

Page 187: Tmql tutorials (english)
Page 188: Tmql tutorials (english)
Page 189: Tmql tutorials (english)
Page 190: Tmql tutorials (english)
Page 191: Tmql tutorials (english)
Page 192: Tmql tutorials (english)
Page 193: Tmql tutorials (english)

No sorting, as no keyword found!

Page 194: Tmql tutorials (english)

unsorted result

{["C", "AA"] ["A", "BA"] ["C", "AB"] ["D", "AD"]}

Result?

1: {["A", "BA"] ["C", "AA"] ["C", "AB"] ["D", "AD"]}

2:

Page 195: Tmql tutorials (english)

Introduction to Topic Maps

10

Sorting - Routine

... (/ Tm. Name [0] / tm. Name [1] ASC)

unsorted result

{["C", "AA"] ["A", "BA"] ["C", "AB"] ["D", "AD"]}

{["A", "BA"] ["C", "AA"] ["C", "AB"] ["D", "AD"]}

Page 196: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de11

Sorting - Routine

Query

... (/ Tm. Name [0] DESC, / tm. Name [1])

unsorted result

{["C", "AA"] ["A", "BA"] ["C", "AB"] ["D", "AD"]}

sorted result?

Page 197: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de12

Sorting - Routine

Query

... (/ Tm. Name [0] DESC, / tm. Name [1])

unsorted result

{["C", "AA"] ["A", "BA"] ["C", "AB"] ["D", "AD"]}

{["D", "AD"] ["C", "AA"] ["C", "AB"] ["A", "BA"]}

Page 198: Tmql tutorials (english)

topicmapslab.de13

... (/ Tm. Name [0] DESC, / tm. Name [1] DESC)

{["C", "AA"] ["A", "BA"] ["C", "AB"] ["D", "AD"]}

sorted result?

Page 199: Tmql tutorials (english)

topicmapslab.de

Sorting - Routine

Page 200: Tmql tutorials (english)
Page 201: Tmql tutorials (english)

Introduction to Topic Maps

Page 202: Tmql tutorials (english)
Page 203: Tmql tutorials (english)
Page 204: Tmql tutorials (english)
Page 205: Tmql tutorials (english)
Page 206: Tmql tutorials (english)

Transitivity

Page 207: Tmql tutorials (english)

topicmapslab.de

Pragma-definition - transitivity

Draft only defined as a transitive pragma

Signature

● identifier: taxonometry

QIRI: tm: intransitive

Page 208: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de23

Pragma-definition - transitivity

% Prefix o http://psi.ontopia.net/

% Prefix tml http://www.topicmapslab.de/

% Pragma taxonometry tm: intransitive

/ / O: Composer + + / / tml: person

Page 209: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofSelect - Style

Page 210: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de25

Select Style

syntactic similarity to SQL

● consists of a set of sub-expressions

● allow binding of variables

● single type with key word for duplicate - treatment andSelection

Page 211: Tmql tutorials (english)

26

<Value-expression>

order

[

Limit

Page 212: Tmql tutorials (english)
Page 213: Tmql tutorials (english)
Page 214: Tmql tutorials (english)
Page 215: Tmql tutorials (english)
Page 216: Tmql tutorials (english)
Page 217: Tmql tutorials (english)
Page 218: Tmql tutorials (english)
Page 219: Tmql tutorials (english)

Commitment to values at run time by conditions●

-

Page 220: Tmql tutorials (english)

Introduction to Topic Maps

predefined variables

● reserved system variables

@ _ Current Tuple

$ # current index

%% Environment Topic Map

% _ requested Topic Map

$ [0-9] + indexed element of a tuple

$ _ write-only variable

Page 221: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de36

Where clause

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

SELECT $ composer

WHERE $ o ISA composer: composer

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

% Prefix l http://psi.ontopia.net/literature/

SELECT $ composer, $ opera

WHERE $ composer ISA o: o AND composer: composed-by (l: work:$ Opera, o: composer: $ composer)

Page 222: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills of

Page 223: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Definition of path expressions

Page 224: Tmql tutorials (english)
Page 225: Tmql tutorials (english)
Page 226: Tmql tutorials (english)
Page 227: Tmql tutorials (english)
Page 228: Tmql tutorials (english)
Page 229: Tmql tutorials (english)
Page 230: Tmql tutorials (english)
Page 231: Tmql tutorials (english)

3. Content Types

● CTM

Page 232: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills ofFLW (O) R-Style

Page 233: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de5

FLW (O) R-Style

● syntactic similarity to XML FLW (O) R or

● limited syntactic thickness (um Cf SELCT)

● allow binding of variables

Page 234: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de6

[< for <Binding-set>>]

[ boolean-expression]

[ by <Value-expression>]

return

Page 235: Tmql tutorials (english)
Page 236: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

→ defined content type and content of return

Page 237: Tmql tutorials (english)

9

→ Topic for Puccini

RETURN wiki: Puccini / tm: name, wiki: Puccini>> indicators

Page 238: Tmql tutorials (english)
Page 239: Tmql tutorials (english)
Page 240: Tmql tutorials (english)
Page 241: Tmql tutorials (english)
Page 242: Tmql tutorials (english)
Page 243: Tmql tutorials (english)
Page 244: Tmql tutorials (english)

RETURN $ composer, $ opera

→ Sort by Name of the composer

Page 245: Tmql tutorials (english)

Introduction to Topic Maps

Language skills ofFor - Clause

Page 246: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de18

For clause

defined range of values to bind variables

can contain multiple binding definitions

● Pattern

FOR variable IN context

For other IN other context-

...

Page 247: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de19

For clause

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

% Prefix l http://psi.ontopia.net/literature/

IN FOR $ composer / o: composer

WHERE o: composed-by (l: work: $ opera, o: composer: $ composer)

ORDER BY $ composer / tm: name [0], $ opera / tm: name [0] DESC

RETURN $ composer, $ opera

→ Area of the variable $ composer limited to all composers

Page 248: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

For clause

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

IN FOR $ composer http://en.wikipedia.org/wiki/Puccini

WHERE o: composed-by (l: work: $ opera, o: composer: $ composer)

ORDER BY $ composer / tm: name [0], $ opera / tm: name [0] DESC

Page 249: Tmql tutorials (english)

Introduction to Topic Maps

Page 250: Tmql tutorials (english)

Variables only have validity within their queries(Inheritance of "child" query)

Page 251: Tmql tutorials (english)

23

Page 252: Tmql tutorials (english)
Page 253: Tmql tutorials (english)
Page 254: Tmql tutorials (english)
Page 255: Tmql tutorials (english)
Page 256: Tmql tutorials (english)

RETURN "" "$ {composer}" ""

Page 257: Tmql tutorials (english)

Introduction to Topic Maps

Page 258: Tmql tutorials (english)

Introduction to Topic Maps

XML - Content

● XML fragments are defined by XML tags

XML fragments can contain a lot of queries

● To use information as XML fragmentsExport (Web Services)

Page 259: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de31

XML - Content

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

% Prefix l http://psi.ontopia.net/literature/

RETURN <yml>

{

IN FOR $ composer / o: composer

RETURN <composer> $ {Composer} </composer>

}

</yml>

Page 260: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de32

XML - Content

● Topic Maps elements are transformed into XTM fragment

● simple data types are translated into strings

Strings are not processed in the current written

Page 261: Tmql tutorials (english)

Introduction to Topic Maps

Page 262: Tmql tutorials (english)

topicmapslab.de

Topic Maps Query Language

Sven Krusty M. Sc.

Topic Maps Lab at the University of Leipzig

[email protected]

Page 263: Tmql tutorials (english)

topicmapslab.de

WHERE Clause

Page 264: Tmql tutorials (english)
Page 265: Tmql tutorials (english)
Page 266: Tmql tutorials (english)
Page 267: Tmql tutorials (english)
Page 268: Tmql tutorials (english)
Page 269: Tmql tutorials (english)
Page 270: Tmql tutorials (english)

Introduction to Topic Maps

Conditional statement NCL

IN FOR $ topic / / tm: subject

RETURN

$ Topic>> indicators>> atomify [0] | | $ topic>> locator>> atomify [0]

Page 271: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

TMQL - Part II

Page 272: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de11

TMQL Part II●

● TMQL based on Part I (TMQL - Query Language)

● syntactically based on the Draft 2007

Page 273: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de12

TMQL Part II● defined change operations for Topic Maps

● Insert operation● Delete operation● Change operation● Merge rules

Page 274: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Language skills of

Page 275: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de14

Insert Expression●

Use of CTM as a definition language

Page 276: Tmql tutorials (english)
Page 277: Tmql tutorials (english)
Page 278: Tmql tutorials (english)
Page 279: Tmql tutorials (english)
Page 280: Tmql tutorials (english)
Page 281: Tmql tutorials (english)
Page 282: Tmql tutorials (english)
Page 283: Tmql tutorials (english)
Page 284: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de23

Merge expression● Merging of Topics under TMDM

● Definition of a set of topics that are to be merged

● Using variables

● Where clause restricts a range of values of the variables

● Grammar

merge-expression:: = MERGE <value-expression>

WHERE boolean-expression

Page 285: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de24

Merge expression

MERGE / / http://psi.example.org/type [. / Email == "[email protected]"]

→ all topics that meet the following condition to be merged

Instance of type http://psi.example.org/type●

● Occurrence is worth at least one of these [email protected]

Page 286: Tmql tutorials (english)

topicmapslab.de25

Merge expression

AND $ person / email == $ other / email

→ People with the same e-mail address are merged

Page 287: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Definition of a set of association which are to merge

merge-expression:: = MERGE association definition

WHERE boolean-expression

Page 288: Tmql tutorials (english)

Introduction to Topic Maps

27

equivalent to Predicate Invocation (limited syntax)

● supply quantity of the Association to match the defined pattern

● Ellipse highlights strict processing

association-definition :: = <Part [...]>

part :: = (Ident | variable) ':' (ident | variable)

Page 289: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de28

Association definition

m: composed-by (

m: composer: http://en.wikipedia.net/wiki/Puccini)

→ delivers all the associations which● of type "composer" is● exact role of type "composer" played by

Puccini has

Page 290: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de29

Association definition

m: composed-by (

tm: subject: http://en.wikipedia.net/wiki/Puccini, ...)

→ delivers all the associations which

● at least played a role of Puccini has→ type of role is not restricted

Page 291: Tmql tutorials (english)

30

% Prefix m http://psi.ontopia.net/music/

MERGE m: composed-by (

tm: subject: http://en.wikipedia.net/wiki/Puccini, ...)

→ merge all associations of type "composed"

Page 292: Tmql tutorials (english)

Conditions

own type

themselves Scope

Page 293: Tmql tutorials (english)
Page 294: Tmql tutorials (english)

Sven Krusty M. Sc.

Page 295: Tmql tutorials (english)
Page 296: Tmql tutorials (english)
Page 297: Tmql tutorials (english)
Page 298: Tmql tutorials (english)
Page 299: Tmql tutorials (english)

optional argument

Value-Ex: new value of the change

Page 300: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

● context-free changes (context, topic map!)

Add new association

→ without CTM

Page 301: Tmql tutorials (english)

topicmapslab.de8

Create New Topic

● Keyword: topics

● Definition of Identifier

● Identifier already in use? → no change

UPDATE topics ADD "http://psi.example.org/topic"

→ no identifier type defined (default: Subject identifier)

Page 302: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de9

Topic with subject identifiers to create

UPDATE topics ADD "http://psi.example.org/topic"

UPDATE topics ADD "http://psi.example.org/topic" ~

UPDATE topics ADD "http://psi.example.org/topic" <<indicators

→ new topic with a subject identifier

Page 303: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Topic with Item Identifier Create

UPDATE topics ADD "http://psi.example.org/topic!

Page 304: Tmql tutorials (english)

topicmapslab.de11

Page 305: Tmql tutorials (english)

Introduction to Topic Maps

UPDATE associations ADD association-type (role-type: player)

→ all topics are not produced in existence

Page 306: Tmql tutorials (english)

Introduction to Topic Maps

Variables can be bound by where clause

Page 307: Tmql tutorials (english)
Page 308: Tmql tutorials (english)
Page 309: Tmql tutorials (english)
Page 310: Tmql tutorials (english)
Page 311: Tmql tutorials (english)

Keyword: names

● Optional: Name type

Context: Topic

WHERE http://en.wikipedia.org/wiki/Puccini

Page 312: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de19

Name change

● Keyword: names

● Optional: no

● Context:

UPDATE names SET "name"

WHERE http://en.wikipedia.org/wiki/Puccini>> characteristicstm: name @ short-name

Page 313: Tmql tutorials (english)

Introduction to Topic Maps

20

Create New Occurrence

● Keyword: occurrences

● Optional:

● Context:

Page 314: Tmql tutorials (english)

topicmapslab.de

● Keyword: occurrences

no

UPDATE SET occurrences "1" ̂ ̂ xsd: integer

Page 315: Tmql tutorials (english)
Page 316: Tmql tutorials (english)
Page 317: Tmql tutorials (english)
Page 318: Tmql tutorials (english)
Page 319: Tmql tutorials (english)

super types

Optional:

● Context: Topic

WHERE http://en.wikipedia.org/wiki/Puccini

Page 320: Tmql tutorials (english)

Introduction to Topic Maps

27

Add new subtype

● subtypes

no

Context: Topic

UPDATE ADD subtypes http://en.wikipedia.org/wiki/Puccini

WHERE http://psi.example.org/type

Page 321: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de28

Players change

● Keyword: players

● Optional: Role type (default: all roles!)

UPDATE players SET composer http://psi.example.org/me

WHERE http://en.wikipedia.org/wiki/Puccini <<players

Page 322: Tmql tutorials (english)

Introduction to Topic Maps

topicmapslab.de

Keyword:

● Topic (players)

Context:

WHERE http://en.wikipedia.org/wiki/Puccini <<players

Page 323: Tmql tutorials (english)

Introduction to Topic Maps

Reifier change

Keyword:

no

Page 324: Tmql tutorials (english)
Page 325: Tmql tutorials (english)
Page 326: Tmql tutorials (english)
Page 327: Tmql tutorials (english)
Page 328: Tmql tutorials (english)