0
Einführung in Topic Maps




                    Topic Maps Query Language




         Sven Krosse M. Sc.
         Topic ...
Einführung in Topic Maps

introduce myself
 Oct. 2004
             –   matriculation at the university of cooperative
    ...
Einführung in Topic Maps

introduce myself
 May 2009
             –   joining the Topic Maps Lab at the university of
    ...
Einführung in Topic Maps

Agenda
1 the Ontopia Topic Maps Engine
  1.1 Omnigator – a generic topic maps browser
  1.2 Inst...
Einführung in Topic Maps

Agenda
3 Introduction of the language TMQL
   3.1 Why do we need a language like TMQL?
   3.2 Ho...
Einführung in Topic Maps

Agenda
5 Learning the high-level expressions
   5.1 Path Expression
   5.2 Select Expression
   ...
Einführung in Topic Maps




      the Ontopia Topic Maps Engine




  topicmapslab.de
                                 to...
Einführung in Topic Maps
the Ontopia Topic Maps Engine
 ●   the topics map engine of the company Ontopia AS
 ●   contains ...
Einführung in Topic Maps
Omnigator – generic topic maps browser
 ●   part of the Ontopia engine
 ●   web-based topic maps ...
Einführung in Topic Maps
Omnigator – generic topic maps browser




  topicmapslab.de
                                    ...
Einführung in Topic Maps
Installing Ontopia with all extensions
 ●   needed components
      ●   JRE 5.0 or higher
      ●...
Einführung in Topic Maps




 TMQL4J - the first Java-based TMQL
               Engine




  topicmapslab.de
             ...
Einführung in Topic Maps
TMQL4J
 ●   TMQL Querying Engine written in Java
 ●   current version 1.0.0
 ●   abstracts from u...
Einführung in Topic Maps
TMQL4J - architecture
 ●   designed as process chain of independent modules
 ●   each module can ...
Einführung in Topic Maps
TMQL4J – process chain



           environment and     cleaned        TMQL lexical             ...
Einführung in Topic Maps
TMQL4J – process chain



           environment and        cleaned        TMQL lexical          ...
Einführung in Topic Maps
TMQL4J – process chain


                              data flow of the TMQL querying process

  ...
Einführung in Topic Maps
TMQL4J – application architecture

                                         application
         ...
Einführung in Topic Maps
TMQL4Ontopia
 ●   generic query plug-in for the Omnigator
 ●   current version 0.0.1
 ●   use the...
Einführung in Topic Maps
result view of TMQL4Ontopia




  topicmapslab.de
                              20
Einführung in Topic Maps
parser tree view of TMQL4Ontopia




  topicmapslab.de
                                   21
Einführung in Topic Maps




   Introduction of the language TMQL




  topicmapslab.de
                                to...
Einführung in Topic Maps
Introduction of the language TMQL
 ●   TMQL is a topic maps query language
 ●   part of ISO stand...
Einführung in Topic Maps
Why do we need a language like TMQL?
 ●   the number of applications using topic maps increases
 ...
Einführung in Topic Maps
Why do we need a language like TMQL?
 ●   Example TMAPI vs TMQL
         → extract all player nam...
Einführung in Topic Maps
●  TMAPI ( for example in Java )
TopicMapSystemFactory factory = TopicMapSystemFactory.newInstanc...
Einführung in Topic Maps

 ●   TMQL4J
TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance();

TopicMapSystem...
Einführung in Topic Maps
How can we use TMQL?
 ●   different opportunities
      ●   TMQL4J
      ●   PerlTM
      ●   Han...
Einführung in Topic Maps
Are there any alternatives for TMQL?
 ●   there are other languages for querying topic maps
     ...
Einführung in Topic Maps
Are there any alternatives for TMQL?
 ●   but:
      ●   there expressiveness are lower than TMQL...
Einführung in Topic Maps




TMQL - the basics of the current draft




  topicmapslab.de
                                ...
Einführung in Topic Maps
TMQL – the basics of the ISO draft
 ●   only the basics of the ISO draft
 ●   basics important to...
Einführung in Topic Maps
TMQL – grammar levels
 ●   define the terminals of the language
 ●   based on Regular Expressions...
Einführung in Topic Maps
TMQL – grammar levels
 ●   define the production rules of TMQL
 ●   combination of terminals
    ...
Einführung in Topic Maps
TMQL – grammar levels
 ●   define the shortcuts as term substitutions
     anchor / tm:name ==> a...
Einführung in Topic Maps
TMQL – literals or atoms
 ●   atoms defined as constant literals
 ●   atoms are data-types and op...
Einführung in Topic Maps
TMQL – literals or atoms
    atom                                    possible value
    atom     ...
Einführung in Topic Maps
TMQL – references
 ●   references used to identify topics in context of a TMQL
     query
 ●   su...
Einführung in Topic Maps
TMQL – references example
 ●   item-identifier
             puccini

 ●   subject-identifier
    ...
Einführung in Topic Maps
TMQL – navigation
 ●   based on the TMRM
 ●   define 12 axes
 ●   can use as a part of path expre...
Einführung in Topic Maps
TMQL – identifier axes
 ●   one axis for each identifier type
 ●   do not supports optional types...
Einführung in Topic Maps
TMQL – identifier axes examples

 ●   item-identifier
             http://psi.ontopedia.net/Pucci...
Einführung in Topic Maps
TMQL – type-hierarchy axes
 ●   supports is-instance-of and a-kind-of associations
 ●   forward-d...
Einführung in Topic Maps
TMQL – type hierarchy axes examples
 ●   type-instance
             http://psi.ontopedia.net/Pucc...
Einführung in Topic Maps
TMQL – association axes
 ●   forward-direction
      ●   deliver all roles of given association (...
Einführung in Topic Maps
TMQL – association axes examples
 ●   roles
             http://psi.ontopedia.net/composed_by >> ...
Einführung in Topic Maps
TMQL – characteristics axis
 ●   forward-direction
      ●   deliver all names and occurrences of...
Einführung in Topic Maps
TMQL – characteristics axis examples
 ●   all names of puccini


              http://psi.ontoped...
Einführung in Topic Maps
TMQL – scope axis
 ●   forward-direction
      ●   deliver the scope of the given construct
     ...
Einführung in Topic Maps
TMQL – scope axis examples

 ●   the scope of the names of puccini
              http://psi.ontop...
Einführung in Topic Maps
TMQL – reifier axis
 ●   forward-direction
      ●   deliver the reifier of the given construct
 ...
Einführung in Topic Maps
TMQL – reifier axis examples

 ●   the construct reified by the topic item A Philatelic
     Hist...
Einführung in Topic Maps
TMQL – atomify axis
 ●   forward-direction
      ●   deliver the value of the given characteristi...
Einführung in Topic Maps
TMQL – atomify axis examples

 ●   the value of the name puccini


                       http://...
Einführung in Topic Maps
TMQL – variables
 ●   using in context of high-level expression
 ●   supported by select expressi...
Einführung in Topic Maps
TMQL – variables


  Tuple

          Tuples are ordered collections of simple values (atoms and ...
Einführung in Topic Maps
TMQL – protected variables
 ●   variable names can post-fixed by different number of primes '
 ● ...
Einführung in Topic Maps
TMQL – variables example
 ●   variables
                       $composer    // can be bind to puc...
Einführung in Topic Maps
TMQL – variables example
 ●   tuple
                       ( puccini , "puccini" , “1900-01-01” )...
Einführung in Topic Maps




   TMQL - the high-level expressions

                    - learning by doing -



  topicmap...
Einführung in Topic Maps
TMQL – Path Expression
 ●   combination of navigation steps or predicate invocations
 ●   predica...
Einführung in Topic Maps
TMQL – predicate-invocation example




   composed_by ( composer : puccini , opera : le_villi , ...
Einführung in Topic Maps
TMQL – predicate-invocation example



        association type




   composed_by ( composer : p...
Einführung in Topic Maps
TMQL – predicate-invocation example



                            role type




   composed_by (...
Einführung in Topic Maps
TMQL – predicate-invocation example



                                      player




   compos...
Einführung in Topic Maps
TMQL – predicate-invocation example



                                              ellipsis



...
Einführung in Topic Maps
TMQL – Path Expression exercises

  Task

                    All names of all instances of compo...
Einführung in Topic Maps
TMQL – Path Expression exercises

  Task

                       All names of all instances of co...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

   The names of all topis playing the role composer in...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

   The names of all topis playing the role composer in...
Einführung in Topic Maps
TMQL – filter and projection
 ●   filters
           –   post-fixed after navigation
           –...
Einführung in Topic Maps
TMQL – filter and projection
 ●   projection
           –   post-fixed after navigation
         ...
Einführung in Topic Maps
TMQL – filter and projection example
 ●   the first name of puccini
      http://psi.ontopedia.ne...
Einführung in Topic Maps
TMQL – filter and projection example



               navigation




      composer << types ( ....
Einführung in Topic Maps
TMQL – filter and projection example



                            projection definition




   ...
Einführung in Topic Maps
TMQL – filter and projection example



                              current node




      comp...
Einführung in Topic Maps
TMQL – filter and projection example



                                        projection




  ...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

     Create a projection of all name and all occurrenc...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

     Create a projection of all name and all occurrenc...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

          All names of all instances of composer in sc...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

             All names of all instances of composer in...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

         Extract the characteristics of all composers ...
Einführung in Topic Maps
TMQL – Path Expression exercises


  Task

         Extract the characteristics of all composers ...
Einführung in Topic Maps
TMQL – Select Expression
 ●   similar to SQL
 ●   supports variables




     topicmapslab.de
   ...
Einführung in Topic Maps
TMQL – Select Clause
 ●   only non-optional clause of a select expression
 ●   starts with the ke...
Einführung in Topic Maps
TMQL – Select Clause example




        SELECT http://psi.ontopedia.net/Puccini / tm:name ,
    ...
Einführung in Topic Maps
TMQL – Where Clause
 ●   optional clause of a select expression
 ●   starts with the keyword WHER...
Einführung in Topic Maps
TMQL – Where Clause example




   SELECT $composer
      WHERE $composer ISA http://psi.ontopedi...
Einführung in Topic Maps
TMQL – Exists Clause
 ●   specifies the number of items satisfying a condition
 ●   numerically u...
Einführung in Topic Maps
TMQL – Exists Clause example

 SELECT $composer
 WHERE EXISTS $composer ISA http://psi.ontopedia....
Einführung in Topic Maps
TMQL – Forall Clause
 ●   all items have to satisfy the condition


     EVERY variable IN conten...
Einführung in Topic Maps
TMQL – Forall Clause example



   SELECT $composer
      WHERE
          EVERY $opera IN $compos...
Einführung in Topic Maps
TMQL – boolean combination
 ●   negation symbolized by the keyword NOT


 ●   conjunction symboli...
Einführung in Topic Maps
TMQL – boolean combination example

   SELECT $composer
      WHERE NOT ( $composer ISA
         ...
Einführung in Topic Maps
TMQL – From Clause
 ●   optional clause of a select expression
 ●   starts with the keyword FROM
...
Einführung in Topic Maps
TMQL – From Clause example




   SELECT $composer
      FROM // http://psi.ontopedia.net/Musicia...
Einführung in Topic Maps
TMQL – Unique Clause
 ●   optional clause of a select expression
 ●   only the keyword UNIQUE
 ● ...
Einführung in Topic Maps
TMQL – Unique Clause example




   SELECT $composer
      FROM // http://psi.ontopedia.net/Music...
Einführung in Topic Maps
TMQL – Order-By Clause
 ●   optional clause of a select expression
 ●   starts with the keyword O...
Einführung in Topic Maps
TMQL – Order-By Clause example




   SELECT $composer
      FROM // http://psi.ontopedia.net/Mus...
Einführung in Topic Maps
TMQL – Limit and Offset
 ●   optional clauses of a select expression
 ●   starts with the keyword...
Einführung in Topic Maps
TMQL – Limit and Offset example



   SELECT $composer
      FROM // http://psi.ontopedia.net/Mus...
Einführung in Topic Maps
TMQL – Select Expression exercises


  Task

                    Select all operas composed by pu...
Einführung in Topic Maps
TMQL – Select Expression exercises


  Task

                     Select all operas composed by p...
Einführung in Topic Maps
TMQL – Select Expression exercises
  Task

   Select the names of all composers who composed at l...
Einführung in Topic Maps
TMQL – Select Expression exercises
  Task

   Select the names of all composers who composed at l...
Einführung in Topic Maps
TMQL – Select Expression exercises


  Task

   Select the topic types which are a kind of compos...
Einführung in Topic Maps
TMQL – Select Expression exercises


  Task

   Select the topic types which are a kind of compos...
Einführung in Topic Maps
TMQL – Flwr Expression
 ●   similar to a programming language
 ●   supports variables




     to...
Einführung in Topic Maps
TMQL – Return Clause
 ●   only non-optional clause of a flwr expression
 ●   starts with the keyw...
Einführung in Topic Maps
TMQL – Return Clause example




   RETURN http://psi.ontopedia.net/Puccini / tm:name




  topic...
Einführung in Topic Maps
TMQL – For Clause
 ●   optional clause of a flwr expression
 ●   starts with the keyword FOR
 ●  ...
Einführung in Topic Maps
TMQL – For Clause example


   FOR $composer IN // http://psi.ontopedia.net/Composer
   RETURN $c...
Einführung in Topic Maps
TMQL – Where Clause and Order-By
 ●   optional clauses of a flwr expression
 ●   same syntax and ...
Einführung in Topic Maps
TMQL – Where Clause and Order-By

   FOR $composer IN // http://psi.ontopedia.net/Composer
   FOR...
Einführung in Topic Maps
TMQL – Flwr Expression exercises

  Task

                    Select all operas composed by pucci...
Einführung in Topic Maps
TMQL – Flwr Expression exercises

  Task

                     Select all operas composed by pucc...
Einführung in Topic Maps




            Thank you for your attention!




  topicmapslab.de
                             ...
Upcoming SlideShare
Loading in...5
×

Hands on TMQL

1,865

Published on

The main problem of modern applications and technologies are the overhead of information. In the context of web 2.0 this problem gains a high priority during the process of development and designing. The high level query language TMQL is the best way to solve this problem. TMQL provides the best opportunity to create different views of the same data base. The benefits are a higher abstraction of the program logic and the high level of control over the business process.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,865
On Slideshare
0
From Embeds
0
Number of Embeds
0
Actions
Shares
0
Downloads
16
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Transcript of "Hands on TMQL"

  1. 1. Einführung in Topic Maps Topic Maps Query Language Sven Krosse M. Sc. Topic Maps Lab an der Universität Leipzig krosse@informatik.uni-leipzig.de topicmapslab.de topicmapslab.de
  2. 2. Einführung in Topic Maps introduce myself Oct. 2004 – matriculation at the university of cooperative education at Leipzig Sep 2007 – graduation in Computer Science with the diploma Oct 2007 – matriculation at the university of Leipzig topicmapslab.de 2
  3. 3. Einführung in Topic Maps introduce myself May 2009 – joining the Topic Maps Lab at the university of Leipzig Sep 2009 – finishing my study with the Master of Computer Science – the subject of my master's thesis was the implementation of TMQL4J topicmapslab.de 3
  4. 4. Einführung in Topic Maps Agenda 1 the Ontopia Topic Maps Engine 1.1 Omnigator – a generic topic maps browser 1.2 Installing Ontopia with all extensions 2 TMQL4J – the first java-based TMQL Engine 2.1 Architecture 2.2 TMQL4Ontopia - Integration into Ontopia topicmapslab.de 4
  5. 5. Einführung in Topic Maps Agenda 3 Introduction of the language TMQL 3.1 Why do we need a language like TMQL? 3.2 How can we use TMQL? 3.3 Are there any alternatives for TMQL? 4 TMQL – the basics of the ISO draft 4.1 grammar levels 4.2 literals and references 4.3 navigation 4.4 variables topicmapslab.de 5
  6. 6. Einführung in Topic Maps Agenda 5 Learning the high-level expressions 5.1 Path Expression 5.2 Select Expression 5.3 Flwr Expression topicmapslab.de 6
  7. 7. Einführung in Topic Maps the Ontopia Topic Maps Engine topicmapslab.de topicmapslab.de
  8. 8. Einführung in Topic Maps the Ontopia Topic Maps Engine ● the topics map engine of the company Ontopia AS ● contains a many tools and utilities for using topic maps ● in summer 2009 the Ontopia topic maps engine becomes open source ● supported by a big community ● supports the TMAPI 2.0 specification topicmapslab.de 8
  9. 9. Einführung in Topic Maps Omnigator – generic topic maps browser ● part of the Ontopia engine ● web-based topic maps browser ● displaying information about topics and associations ● running on a Apache Tomcat server topicmapslab.de 9
  10. 10. Einführung in Topic Maps Omnigator – generic topic maps browser topicmapslab.de 10
  11. 11. Einführung in Topic Maps Installing Ontopia with all extensions ● needed components ● JRE 5.0 or higher ● Ontopia distribution ● tmql4j library ● tmql4Ontopia library ● a web browser :) topicmapslab.de 11
  12. 12. Einführung in Topic Maps TMQL4J - the first Java-based TMQL Engine topicmapslab.de topicmapslab.de
  13. 13. Einführung in Topic Maps TMQL4J ● TMQL Querying Engine written in Java ● current version 1.0.0 ● abstracts from underlying topic map engine ● creates an abstraction layer on top of the TMAPI ● encapsulate the whole querying process ● implements additional cache mechanism ● simple configuration mechanism topicmapslab.de 13
  14. 14. Einführung in Topic Maps TMQL4J - architecture ● designed as process chain of independent modules ● each module can replace by a domain-specific implementation ● based modules – TMQL4J pre-processor – TMQL4J lexer – TMQL4J parser – TMQL4J interpreter – TMQL4J post-processor topicmapslab.de 14
  15. 15. Einführung in Topic Maps TMQL4J – process chain environment and cleaned TMQL lexical transformed parser tree matches system variables TMQL query tokens results TMQL TMQL4J TMQL4J TMQL4J Initialization TMQL4J lexer TMQL4J parser results query pre-processor interpreter post-processor topicmapslab.de 15
  16. 16. Einführung in Topic Maps TMQL4J – process chain environment and cleaned TMQL lexical transformed parser tree matches system variables TMQL query tokens results TMQL TMQL4J TMQL4J TMQL4J Initialization TMQL4J lexer TMQL4J parser results query pre-processor interpreter post-processor process flow of the TMQL querying process topicmapslab.de 16
  17. 17. Einführung in Topic Maps TMQL4J – process chain data flow of the TMQL querying process environment and cleaned TMQL lexical transformed parser tree matches system variables TMQL query tokens results TMQL TMQL4J TMQL4J TMQL4J Initialization TMQL4J lexer TMQL4J parser results query pre-processor interpreter post-processor topicmapslab.de 17
  18. 18. Einführung in Topic Maps TMQL4J – application architecture application TMQL query direct access TMQL4J indirect access TMAPI topic maps engine topic maps backend topicmapslab.de 18
  19. 19. Einführung in Topic Maps TMQL4Ontopia ● generic query plug-in for the Omnigator ● current version 0.0.1 ● use the TMQL4J engine ● implements Ontopia specific modules ● allows result export as CSV file topicmapslab.de 19
  20. 20. Einführung in Topic Maps result view of TMQL4Ontopia topicmapslab.de 20
  21. 21. Einführung in Topic Maps parser tree view of TMQL4Ontopia topicmapslab.de 21
  22. 22. Einführung in Topic Maps Introduction of the language TMQL topicmapslab.de topicmapslab.de
  23. 23. Einführung in Topic Maps Introduction of the language TMQL ● TMQL is a topic maps query language ● part of ISO standardization ( ISO 18048 ) ● discussions about parts of the final standard ● supports different styles of querying ● supports the definition of ontology in context of a query topicmapslab.de 23
  24. 24. Einführung in Topic Maps Why do we need a language like TMQL? ● the number of applications using topic maps increases fast ● the data base becomes to complex ● complex handling by using TMAPI code fragments ● complex terminology and ontology ● number of topics and associations too huge ● different views of the data in context of different business processes topicmapslab.de 24
  25. 25. Einführung in Topic Maps Why do we need a language like TMQL? ● Example TMAPI vs TMQL → extract all player names of the association member_of topicmapslab.de 25
  26. 26. Einführung in Topic Maps ● TMAPI ( for example in Java ) TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); TopicMapSystem topicMapSystem = factory.newTopicMapSystem(); TopicMap topicMap = topicMapSystem.getTopicMap("my-topic-map"); // type of the association Topic type = (Topic)topicMap.getConstructById("member_of"); // extract all association items of the type member-of TypeInstanceIndex index = topicMap.getIndex(TypeInstanceIndex.class); for ( Association association : index.getAssociations(type)){ // extract all roles of the association item for ( Role role : association.getRoles()){ // extract the role player and the names names.addAll(role.getPlayer().getNames()); } topicmapslab.de 26
  27. 27. Einführung in Topic Maps ● TMQL4J TopicMapSystemFactory factory = TopicMapSystemFactory.newInstance(); TopicMapSystem topicMapSystem = factory.newTopicMapSystem(); TopicMap topicMap = topicMapSystem.getTopicMap("my-topic-map"); // initialize the tmql4j engine IQuery query = new QueryImpl("member_of << types >> players / tm:name") TMQLRuntime runtime = new TMQLRuntime(topicMapSystem, Arrays.asList(new TopicMap[] { topicMap }), query); runtime.run(); // extract result set names.addAll((ITupleSequence<Name>) runtime .getStoredValue(TMQLRuntime.TMQL_RUNTIME_RESULTPROCESSING_RESULT)); topicmapslab.de 27
  28. 28. Einführung in Topic Maps How can we use TMQL? ● different opportunities ● TMQL4J ● PerlTM ● Hands on ;-) topicmapslab.de 28
  29. 29. Einführung in Topic Maps Are there any alternatives for TMQL? ● there are other languages for querying topic maps ● Tolog – a language similar to Prolog – supports predicate-invocations and boolean combinations ● Toma – a language similar to SQL – developed by Rani Pinchuk topicmapslab.de 29
  30. 30. Einführung in Topic Maps Are there any alternatives for TMQL? ● but: ● there expressiveness are lower than TMQL ● TMQL supports different query styles for different domains topicmapslab.de 30
  31. 31. Einführung in Topic Maps TMQL - the basics of the current draft topicmapslab.de topicmapslab.de
  32. 32. Einführung in Topic Maps TMQL – the basics of the ISO draft ● only the basics of the ISO draft ● basics important to understand the syntax of TMQL ● learning high-level expressions by doing topicmapslab.de 32
  33. 33. Einführung in Topic Maps TMQL – grammar levels ● define the terminals of the language ● based on Regular Expressions example: $variable | SELECT | FOR Token Level topicmapslab.de 33
  34. 34. Einführung in Topic Maps TMQL – grammar levels ● define the production rules of TMQL ● combination of terminals example: tuple-expression := <value-expression> Canonical Level Token Level topicmapslab.de 34
  35. 35. Einführung in Topic Maps TMQL – grammar levels ● define the shortcuts as term substitutions anchor / tm:name ==> anchor >> chracteristics tm:name Non-Canonical Level Canonical Level Token Level topicmapslab.de 35
  36. 36. Einführung in Topic Maps TMQL – literals or atoms ● atoms defined as constant literals ● atoms are data-types and operators ● supported data-types are an extract of the CTM data- types and XSD date and dateTime topicmapslab.de 36
  37. 37. Einführung in Topic Maps TMQL – literals or atoms atom possible value atom 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 /"([^"]|")*"/ | /'([^']|')*'/ source: http://www.isotopicmaps.org/tmql/tmql.html topicmapslab.de 37
  38. 38. Einführung in Topic Maps TMQL – references ● references used to identify topics in context of a TMQL query ● supports – item-identifier – subject-identifier – subject-locators ● possible to use relative IRI as identifier or locator topicmapslab.de 38
  39. 39. Einführung in Topic Maps TMQL – references example ● item-identifier puccini ● subject-identifier http://psi.ontopedia.net/Puccini ● subject-locator http://psi.ontopedia.net/Puccini topicmapslab.de 39
  40. 40. Einführung in Topic Maps TMQL – navigation ● based on the TMRM ● define 12 axes ● can use as a part of path expression ● symbolize navigation throw the abstract topic map graph ● each axis can used in two directions ● syntax navigation := axis-name direction optional-type direction := << | >> topicmapslab.de 40
  41. 41. Einführung in Topic Maps TMQL – identifier axes ● one axis for each identifier type ● do not supports optional types ● forward-direction ● deliver the identifier of the given topic ● only supports topic items ● backward-direction ● deliver the topic with this identifier ● only supports string literals topicmapslab.de 41
  42. 42. Einführung in Topic Maps TMQL – identifier axes examples ● item-identifier http://psi.ontopedia.net/Puccini >> item ● subject-identifier http://psi.ontopedia.net/Puccini >> indicators ● subject-locator http://psi.ontopedia.net/Puccini << locators topicmapslab.de 42
  43. 43. Einführung in Topic Maps TMQL – type-hierarchy axes ● supports is-instance-of and a-kind-of associations ● forward-direction ● deliver the types of given instance ( type-instance) ● deliver the supertypes of given type ( supertype-subtype) ● supports topic items or association items ● backward-direction ● deliver the instances of given type ( type-instance) ● deliver the subtypes of given type ( supertype-subtype) ● supports topic items or association items topicmapslab.de 43
  44. 44. Einführung in Topic Maps TMQL – type hierarchy axes examples ● type-instance http://psi.ontopedia.net/Puccini >> types http://psi.ontopedia.net/Composer << types ● supertype-subtype http://psi.ontopedia.net/Composer >> supertypes http://psi.ontopedia.net/Composer << supertypes topicmapslab.de 44
  45. 45. Einführung in Topic Maps TMQL – association axes ● forward-direction ● deliver all roles of given association ( roles ) ● deliver all players of given association ( players ) ● deliver all players playing with given topic ( traverse ) ● backward-direction ● deliver all association items using the given role ( roles ) ● deliver all association items using the given player ( players ) ● deliver all associations items connected with the given association by the same player ( traverse ) topicmapslab.de 45
  46. 46. Einführung in Topic Maps TMQL – association axes examples ● roles http://psi.ontopedia.net/composed_by >> roles http://psi.ontopedia.net/Composer << roles ● players http://psi.ontopedia.net/composed_by >> players http://psi.ontopedia.net/Puccini << players ● traverse http://psi.ontopedia.net/Puccini >> traverse http://psi.ontopedia.net/composed_by << traversee topicmapslab.de 46
  47. 47. Einführung in Topic Maps TMQL – characteristics axis ● forward-direction ● deliver all names and occurrences of given topic ● only supports topic items ● backward-direction ● deliver the topic item using the given characteristic ● only supports names and occurrences topicmapslab.de 47
  48. 48. Einführung in Topic Maps TMQL – characteristics axis examples ● all names of puccini http://psi.ontopedia.net/Puccini >> characteristics tm:name ● all occurrences of puccini http://psi.ontopedia.net/Puccini >> characteristics tm:occurrence topicmapslab.de 48
  49. 49. Einführung in Topic Maps TMQL – scope axis ● forward-direction ● deliver the scope of the given construct ● supports names, occurrences or associations ● backward-direction ● deliver all constructs with the given scope ● only supports topic items topicmapslab.de 49
  50. 50. Einführung in Topic Maps TMQL – scope axis examples ● the scope of the names of puccini http://psi.ontopedia.net/Puccini >> characteristics tm:name >> scope ● all constructs with the scope web http://psi.ontopedia.net/Web << scope topicmapslab.de 50
  51. 51. Einführung in Topic Maps TMQL – reifier axis ● forward-direction ● deliver the reifier of the given construct ● supports names, occurrences or associations ● backward-direction ● deliver the construct reifies by the given topic item ● only supports topic items topicmapslab.de 51
  52. 52. Einführung in Topic Maps TMQL – reifier axis examples ● the construct reified by the topic item A Philatelic History http://home.prcn.org/~pauld/opera/ >> reifier ● the reifier of this construct http://home.prcn.org/~pauld/opera/ >> reifier << reifier topicmapslab.de 52
  53. 53. Einführung in Topic Maps TMQL – atomify axis ● forward-direction ● deliver the value of the given characteristics ● supports names or occurrences ● backward-direction ● deliver the characteristics with the given value ● supports all literals topicmapslab.de 53
  54. 54. Einführung in Topic Maps TMQL – atomify axis examples ● the value of the name puccini http://psi.ontopedia.net/Puccini >> characteristics tm:name >> atomify or http://psi.ontopedia.net/Puccini / tm:name topicmapslab.de 54
  55. 55. Einführung in Topic Maps TMQL – variables ● using in context of high-level expression ● supported by select expression and flwr expression ● different prefixes $ only bind literals or items @ only bind a tuple % only bind a sequence topicmapslab.de 55
  56. 56. Einführung in Topic Maps TMQL – variables Tuple Tuples are ordered collections of simple values (atoms and items). Tuple-Sequence Tuple sequences are sequences of tuples where all tuples have identical length. Tuple sequences can be generated with tuple expressions. topicmapslab.de 56
  57. 57. Einführung in Topic Maps TMQL – protected variables ● variable names can post-fixed by different number of primes ' ● variables only differ in number of primes ● can not be bind to the same value topicmapslab.de 57
  58. 58. Einführung in Topic Maps TMQL – variables example ● variables $composer // can be bind to puccini @composers // can be bind to a tuple %composers // can be bind to a sequence topicmapslab.de 58
  59. 59. Einführung in Topic Maps TMQL – variables example ● tuple ( puccini , "puccini" , “1900-01-01” ) ● sequence { ( puccini , "puccini" , “1900-01-01” ) , ( fontane , "fontane" , “1900-01-01” ) } topicmapslab.de 59
  60. 60. Einführung in Topic Maps TMQL - the high-level expressions - learning by doing - topicmapslab.de topicmapslab.de
  61. 61. Einführung in Topic Maps TMQL – Path Expression ● combination of navigation steps or predicate invocations ● predicate-invocation – describe associations – similar to tolog topicmapslab.de 61
  62. 62. Einführung in Topic Maps TMQL – predicate-invocation example composed_by ( composer : puccini , opera : le_villi , … ) topicmapslab.de 62
  63. 63. Einführung in Topic Maps TMQL – predicate-invocation example association type composed_by ( composer : puccini , opera : le_villi , … ) topicmapslab.de 63
  64. 64. Einführung in Topic Maps TMQL – predicate-invocation example role type composed_by ( composer : puccini , opera : le_villi , … ) topicmapslab.de 64
  65. 65. Einführung in Topic Maps TMQL – predicate-invocation example player composed_by ( composer : puccini , opera : le_villi , … ) topicmapslab.de 65
  66. 66. Einführung in Topic Maps TMQL – predicate-invocation example ellipsis composed_by ( composer : puccini , opera : le_villi , … ) topicmapslab.de 66
  67. 67. Einführung in Topic Maps TMQL – Path Expression exercises Task All names of all instances of composer topicmapslab.de 67
  68. 68. Einführung in Topic Maps TMQL – Path Expression exercises Task All names of all instances of composer Solution composer << types >> characteristics tm:name or http://psi.ontopedia.net/Composer << types >> characteristics tm:name topicmapslab.de 68
  69. 69. Einführung in Topic Maps TMQL – Path Expression exercises Task The names of all topis playing the role composer in association composed_by. topicmapslab.de 69
  70. 70. Einführung in Topic Maps TMQL – Path Expression exercises Task The names of all topis playing the role composer in association composed_by. Solution composed_by >> players composed >> characteristics tm:name or http://psi.ontopedia.net/composed_by >> players http://psi.ontopedia.net/Composer >> characteristics tm:name topicmapslab.de 70
  71. 71. Einführung in Topic Maps TMQL – filter and projection ● filters – post-fixed after navigation – surrounded by square brackets – supported filters – index [ number ] – index-range [ number .. number ] – types [ ^ type ] – scope [ @ scope ] – boolean-expressions [ … ] topicmapslab.de 71
  72. 72. Einführung in Topic Maps TMQL – filter and projection ● projection – post-fixed after navigation – surrounded by round brackets – defined as a tuple-expression – simple navigation from current node – current node symbolize by dot topicmapslab.de 72
  73. 73. Einführung in Topic Maps TMQL – filter and projection example ● the first name of puccini http://psi.ontopedia.net/Puccini >> characteristics tm:name [0] ● Projection of characteristics and associations played by instances of composer http://psi.ontopedia.net/Composer << types ( . >> characteristics , . << players ) topicmapslab.de 73
  74. 74. Einführung in Topic Maps TMQL – filter and projection example navigation composer << types ( . >> characteristics , . << players ) topicmapslab.de 74
  75. 75. Einführung in Topic Maps TMQL – filter and projection example projection definition composer << types ( . >> characteristics , . << players ) topicmapslab.de 75
  76. 76. Einführung in Topic Maps TMQL – filter and projection example current node composer << types ( . >> characteristics , . << players ) topicmapslab.de 76
  77. 77. Einführung in Topic Maps TMQL – filter and projection example projection composer << types ( . >> characteristics , . << players ) topicmapslab.de 77
  78. 78. Einführung in Topic Maps TMQL – Path Expression exercises Task Create a projection of all name and all occurrence values of all instances of composer. topicmapslab.de 78
  79. 79. Einführung in Topic Maps TMQL – Path Expression exercises Task Create a projection of all name and all occurrence values of all instances of composer. Solution composer << types ( . / tm:name , . / tm:occurrence ) or http://psi.ontopedia.net/Composer << types( . / tm:name, . / tm:occurrence ) topicmapslab.de 79
  80. 80. Einführung in Topic Maps TMQL – Path Expression exercises Task All names of all instances of composer in scope short name. topicmapslab.de 80
  81. 81. Einführung in Topic Maps TMQL – Path Expression exercises Task All names of all instances of composer in scope short name. Solution composer << types >> characteristics tm:name @ short_name or http://psi.ontopedia.net/Composer << types >> characteristics [ @ http://psi.ontopedia.net/short_name ] topicmapslab.de 81
  82. 82. Einführung in Topic Maps TMQL – Path Expression exercises Task Extract the characteristics of all composers and filter them by the type date_of_death. topicmapslab.de 82
  83. 83. Einführung in Topic Maps TMQL – Path Expression exercises Task Extract the characteristics of all composers and filter them by the type date_of_death. Solution composer << types >> characteristics [ ^ date_of_death ] or http://psi.ontopedia.net/Composer << types >> characteristics [ ^ http://psi.ontopedia.net/date_of_death ] topicmapslab.de 83
  84. 84. Einführung in Topic Maps TMQL – Select Expression ● similar to SQL ● supports variables topicmapslab.de 84
  85. 85. Einführung in Topic Maps TMQL – Select Clause ● only non-optional clause of a select expression ● starts with the keyword SELECT ● contains a number of value expressions – variables – navigations – functions topicmapslab.de 85
  86. 86. Einführung in Topic Maps TMQL – Select Clause example SELECT http://psi.ontopedia.net/Puccini / tm:name , http://psi.ontopedia.net/Puccini / tm:occurrence topicmapslab.de 86
  87. 87. Einführung in Topic Maps TMQL – Where Clause ● optional clause of a select expression ● starts with the keyword WHERE ● contains a number of boolean-expressions – exists-clause – forall-clause – negation – conjunction – disjunction topicmapslab.de 87
  88. 88. Einführung in Topic Maps TMQL – Where Clause example SELECT $composer WHERE $composer ISA http://psi.ontopedia.net/Composer topicmapslab.de 88
  89. 89. Einführung in Topic Maps TMQL – Exists Clause ● specifies the number of items satisfying a condition ● numerically unrestricted – number of satisfying items is not important – starts with keyword EXISTS or SOME – can contain path expressions ● numerically restricted – define the number of satisfying items as upper or lower bounds AT LEAST number set SATISFIES boolean-expression AT MOST number set SATISFIES boolean-expression topicmapslab.de 89
  90. 90. Einführung in Topic Maps TMQL – Exists Clause example SELECT $composer WHERE EXISTS $composer ISA http://psi.ontopedia.net/Composer SELECT $composer WHERE AT LEAST 4 $opera IN // http://psi.ontopedia.net/Opera SATISFIES http://psi.ontopedia.net/composed_by ( http://psi.ontopedia.net/Composer : $composer , http://psi.ontopedia.net/Work : $work ) topicmapslab.de 90
  91. 91. Einführung in Topic Maps TMQL – Forall Clause ● all items have to satisfy the condition EVERY variable IN content SATISFIES boolean-expression topicmapslab.de 91
  92. 92. Einführung in Topic Maps TMQL – Forall Clause example SELECT $composer WHERE EVERY $opera IN $composer << traverse SATISFIES $opera == http://psi.ontopedia.net/Le_Villi topicmapslab.de 92
  93. 93. Einführung in Topic Maps TMQL – boolean combination ● negation symbolized by the keyword NOT ● conjunction symbolized by the keyword AND ● disjunction symbolized by the keyword OR topicmapslab.de 93
  94. 94. Einführung in Topic Maps TMQL – boolean combination example SELECT $composer WHERE NOT ( $composer ISA http://psi.ontopedia.net/Composer ) SELECT $composer , $opera WHERE $composer ISA http://psi.ontopedia.net/Composer AND $opera ISA http://psi.ontopedia.net/Opera topicmapslab.de 94
  95. 95. Einführung in Topic Maps TMQL – From Clause ● optional clause of a select expression ● starts with the keyword FROM ● define the context of the select expression ● have to return a topic map or sequence of constructs topicmapslab.de 95
  96. 96. Einführung in Topic Maps TMQL – From Clause example SELECT $composer FROM // http://psi.ontopedia.net/Musician WHERE $composer ISA http://psi.ontopedia.net/Composer topicmapslab.de 96
  97. 97. Einführung in Topic Maps TMQL – Unique Clause ● optional clause of a select expression ● only the keyword UNIQUE ● unify the result set topicmapslab.de 97
  98. 98. Einführung in Topic Maps TMQL – Unique Clause example SELECT $composer FROM // http://psi.ontopedia.net/Musician WHERE $composer ISA http://psi.ontopedia.net/Composer UNIQUE topicmapslab.de 98
  99. 99. Einführung in Topic Maps TMQL – Order-By Clause ● optional clause of a select expression ● starts with the keyword ORDER BY ● define an order of the variable bindings of the where clause topicmapslab.de 99
  100. 100. Einführung in Topic Maps TMQL – Order-By Clause example SELECT $composer FROM // http://psi.ontopedia.net/Musician WHERE $composer ISA http://psi.ontopedia.net/Composer ORDER BY $composer / tm:name topicmapslab.de 100
  101. 101. Einführung in Topic Maps TMQL – Limit and Offset ● optional clauses of a select expression ● starts with the keyword LIMIT or OFFSET ● define the selection window after querying topicmapslab.de 101
  102. 102. Einführung in Topic Maps TMQL – Limit and Offset example SELECT $composer FROM // http://psi.ontopedia.net/Musician WHERE $composer ISA http://psi.ontopedia.net/Composer ORDER BY $composer / tm:name OFFSET 2 LIMIT 10 topicmapslab.de 102
  103. 103. Einführung in Topic Maps TMQL – Select Expression exercises Task Select all operas composed by puccini. topicmapslab.de 103
  104. 104. Einführung in Topic Maps TMQL – Select Expression exercises Task Select all operas composed by puccini. Solution SELECT $opera WHERE composed_by ( composer : puccini , work : $opera ) or SELECT $opera WHERE http://psi.ontopedia.net/composed_by ( http://psi.ontopedia.net/Composer : http://psi.ontopedia.net/Puccini , http://psi.ontopedia.net/Work : $opera ) topicmapslab.de 104
  105. 105. Einführung in Topic Maps TMQL – Select Expression exercises Task Select the names of all composers who composed at least one opera. Keep in mind that the work should not be an opera. topicmapslab.de 105
  106. 106. Einführung in Topic Maps TMQL – Select Expression exercises Task Select the names of all composers who composed at least one opera. Keep in mind that the work should not be an opera. Solution SELECT $composer / tm:name WHERE $opera ISA opera AND AT MOST 3 SATISFIES composed_by ( work : $opera , composer : $composer ) or SELECT $composer / tm:name WHERE $composer ISA http://psi.ontopedia.net/Composer AND SOME $opera IN // http://psi.ontopedia.net/Opera SATISFIES http://psi.ontopedia.net/composed_by ( http://psi.ontopedia.net/Work : $opera , http://psi.ontopedia.net/Composer : $composer ) topicmapslab.de 106
  107. 107. Einführung in Topic Maps TMQL – Select Expression exercises Task Select the topic types which are a kind of composer or where each instance have at least one name. topicmapslab.de 107
  108. 108. Einführung in Topic Maps TMQL – Select Expression exercises Task Select the topic types which are a kind of composer or where each instance have at least one name. Solution SELECT $type WHERE $type AKO composer OR EXISTS $type << types / tm:name or SELECT $type WHERE $type AKO http://psi.ontopedia.net/Composer OR EXISTS $type << types / tm:name topicmapslab.de 108
  109. 109. Einführung in Topic Maps TMQL – Flwr Expression ● similar to a programming language ● supports variables topicmapslab.de 109
  110. 110. Einführung in Topic Maps TMQL – Return Clause ● only non-optional clause of a flwr expression ● starts with the keyword RETURN ● contains a number of value expressions – variables – navigations – functions – XTM and CTM fragments topicmapslab.de 110
  111. 111. Einführung in Topic Maps TMQL – Return Clause example RETURN http://psi.ontopedia.net/Puccini / tm:name topicmapslab.de 111
  112. 112. Einführung in Topic Maps TMQL – For Clause ● optional clause of a flwr expression ● starts with the keyword FOR ● can contain more than one for clause ● define a variable set topicmapslab.de 112
  113. 113. Einführung in Topic Maps TMQL – For Clause example FOR $composer IN // http://psi.ontopedia.net/Composer RETURN $composer FOR $composer IN // http://psi.ontopedia.net/Composer FOR $opera IN // http://psi.ontopedia.net/Opera RETURN $composer, $opera topicmapslab.de 113
  114. 114. Einführung in Topic Maps TMQL – Where Clause and Order-By ● optional clauses of a flwr expression ● same syntax and meaning like as a part of select expressions topicmapslab.de 114
  115. 115. Einführung in Topic Maps TMQL – Where Clause and Order-By FOR $composer IN // http://psi.ontopedia.net/Composer FOR $opera IN // http://psi.ontopedia.net/Opera WHERE http://psi.ontopedia.net/composed_by( http://psi.ontopedia.net/Composer : $composer , http://psi.ontopedia.net/Work : $opera) ORDER BY $composer >> item RETURN $composer, $opera topicmapslab.de 115
  116. 116. Einführung in Topic Maps TMQL – Flwr Expression exercises Task Select all operas composed by puccini. topicmapslab.de 116
  117. 117. Einführung in Topic Maps TMQL – Flwr Expression exercises Task Select all operas composed by puccini. Solution FOR $opera IN opera WHERE composed_by ( composer : puccini , work : $opera ) RETURN $opera or FOR $opera IN http://psi.ontopedia.net/Opera WHERE http://psi.ontopedia.net/composed_by ( http://psi.ontopedia.net/Composer : http://psi.ontopedia.net/Puccini , http://psi.ontopedia.net/Work : $opera ) RETURN $opera topicmapslab.de 117
  118. 118. Einführung in Topic Maps Thank you for your attention! topicmapslab.de topicmapslab.de
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×