SlideShare ist ein Scribd-Unternehmen logo
1 von 32
Downloaden Sie, um offline zu lesen
Einführung in Topic Maps




                    Topic Maps Query Language
                                Session 7




         Sven Krosse M. Sc.
         Topic Maps Lab an der Universität Leipzig
         krosse@informatik.uni-leipzig.de



  topicmapslab.de
Einführung in Topic Maps
Review – Session 6
 1. FLW(O)R Style
    ●   RETURN-Clause
    ●   WHERE-Clause
    ●   ORDER-BY Clause
    ●   FOR-Clause
 2. Verschachtelung
 3. Content Types
    ●   XML
    ●   CTM
  topicmapslab.de
Einführung in Topic Maps
Agenda
Useful TMQL Expression
 1. If-Then-Else
TMQL Part II
 1. Delete Expression
 2. Insert Expression
 3. Merge Expression




   topicmapslab.de
Einführung in Topic Maps




                   Sprachbestandteile
                        Useful Expression




 topicmapslab.de
Einführung in Topic Maps
Bedingte Anweisung
 ●   bedingte Auswertung von Ergebnissen
 ●   erlaubt bedingte Verzweigung zur Verarbeitungszeit
 ●   Grammatik


     content      ::= if path-expression then content
                       [ else content ]




     topicmapslab.de
                                                          5
Einführung in Topic Maps
Bedingte Anweisung
 ●   Pfadausdruck nach Schlüsselwort IF bestimmt Verzweigung
      ●   leere Menge → ELSE-Zweig
 ●   ELSE-Zweig ist optional → leere Menge bei fehlender Definition




     topicmapslab.de
                                                                      6
Einführung in Topic Maps
Bedingte Anweisung
%prefix o http://psi.ontopia.net/music/
FOR $topic IN // tm:subject
RETURN
   IF $topic ISA o:composer
   THEN $topic >> indicators
   ELSE $topic / tm:name [0]




   topicmapslab.de
                                          7
Einführung in Topic Maps
Bedingte Anweisung NCL
 ●   Kurzform für bedingte Anweisung
 ●   Bedingung repräsentiert „Then“-Zweig
 ●   Grammatik


     content      ::= path-expression || path-expression




     topicmapslab.de
                                                           8
Einführung in Topic Maps
Bedingte Anweisung NCL
%prefix o http://psi.ontopia.net/music/
FOR $topic IN // tm:subject
RETURN
  $topic >> indicators >> atomify [0] || $topic >> locators >> atomify [0]




   topicmapslab.de
                                                                             9
Einführung in Topic Maps




                   TMQL – Part II




 topicmapslab.de
Einführung in Topic Maps
TMQL Part II
 ●   kein ISO-Standard oder Draft
 ●   basiert auf TMQL Part I ( TMQL – Query Language )
 ●   basiert syntaktisch auf dem Draft 2007




     topicmapslab.de
                                                         11
Einführung in Topic Maps
TMQL Part II
 ●   definiert Veränderungsoperationen für Topic Maps
      ●   Einfügeoperation
      ●   Löschoperation
      ●   Änderungsoperation
      ●   Merge-Regeln




     topicmapslab.de
                                                        12
Einführung in Topic Maps




                   Sprachbestandteile
                        Insert Expression




 topicmapslab.de
Einführung in Topic Maps
Insert Expression
 ●   Erzeugen neuer Topic Maps Konstrukte
 ●   Verwendung von CTM als Definitionssprache
      ●   CTM-Content äquivalent zu FLW(O)R Style
 ●   Verwendung von Variablen (gebunden durch Where-Klausel)
 ●   erlaubt auch Änderung bestehender Elemente




     topicmapslab.de
                                                               14
Einführung in Topic Maps
Insert Expression
 ●   Grammatik
         insert-expression ::=   INSERT “““ctm-stream “““
                                 { WHERE query-expression }




     topicmapslab.de
                                                              15
Einführung in Topic Maps
Insert Expression
 INSERT “““ <http://psi.example.org/topic>. “““
 → Fügt ein neues Topic mit dem Subject-Identifier hinzu


 INSERT “““ { $topic >> indicators >> atomify [0] ISA
             <http://psi.example.org/topic> . } “““
             WHERE $topic ISA tm:subject


 → Fügt jedem Topic den Typ http://psi.example.org/topic hinzu


    topicmapslab.de
                                                                 16
Einführung in Topic Maps




                   Sprachbestandteile
                        Delete Expression




 topicmapslab.de
Einführung in Topic Maps
Delete Expression
 ●   Entfernen bestehender Topic Maps Konstrukte
 ●   Adressierung von Konstrukten über Pfadausdruck
 ●   Abhängigkeit werden nicht automatisch entfernt (z.B. Topic als Reifier,
     Topic als Typ)




     topicmapslab.de
                                                                               18
Einführung in Topic Maps
Delete Expression
 ●   direkte Adressierung über Pfadausdruck und Filter
 ●   Grammatik
     delete-expression ::= DELETE { CASCADE } simple-content {filter-postfix}
                          WHERE boolean-expression


 ●   Schlüsselwort CASCADE definiert Löschen aller Abhängigkeiten
 ●   nicht kaskadiert ( Löschen wird abgebrochen )
 ●   Where-Klausel definiert Wertebereich der Variablen


     topicmapslab.de
                                                                            19
Einführung in Topic Maps
Delete Expression
   DELETE CASCADE http://en.wikipedia.org/wiki/Puccini
   → entfernt das Topic Puccini und alle seine Abhängigkeiten
        –   gespielte Rollen und Assoziation
        –   alle Namen und Occurrences
        –   Verwendung als Theme (Konstrukte werden gelöscht)
        –   Verwendung als Reifier (Reifikation wird aufgehoben)




  topicmapslab.de
                                                                   20
Einführung in Topic Maps
Delete Expression
   DELETE CASCADE http://psi.ontopia.net/music/composer >> instances
   → entfernt alle Komponisten aus der Topic Map


   DELETE CASCADE ALL
   → entfernt jegliche Konstrukte aus der Topic Map




  topicmapslab.de
                                                                       21
Einführung in Topic Maps




                   Sprachbestandteile
                        Merge Expression




 topicmapslab.de
Einführung in Topic Maps
Merge Expression
 ●   Mergen von Topics gemäß TMDM
 ●   Definition einer Menge von Topics, welche gemergt werden sollen
 ●   Verwendung von Variablen
 ●   Where-Klausel schränkt Wertebereich der Variablen ein
 ●   Grammatik
         merge-expression ::= MERGE <value-expression>
                                WHERE boolean-expression




     topicmapslab.de
                                                                       23
Einführung in Topic Maps
Merge Expression
MERGE // http://psi.example.org/type [ . / email == „person@gmail.com“ ]


→ alle Topics, welche die folgenden Bedingung erfüllen, werden gemergt
    ●   Instanz vom Typ http://psi.example.org/type
    ●   besitzen mindestens eine Occurrence vom Typ email
    ●   Wert mindestens einer dieser Occurrence ist person@gmail.com




   topicmapslab.de
                                                                         24
Einführung in Topic Maps
Merge Expression
MERGE $person, $other
WHERE $person ISA person AND $other ISA person
   AND $person / email == $other / email


→ Personen mit der selben E-Mail Adresse werden gemergt




  topicmapslab.de
                                                          25
Einführung in Topic Maps
Merge Expression
 ●   Mergen von Assoziation
 ●   Definition einer Menge von Assoziation, welche verschmelzen sollen


 ●   Grammatik
         merge-expression ::= MERGE association-definition
                               WHERE boolean-expression




     topicmapslab.de
                                                                          26
Einführung in Topic Maps
Association-Definition
 ●   äquivalent zu Predicate-Invocation (eingeschränkte Syntax)
 ●   liefern Menge von Assoziation passend zum definierten Muster
 ●   Ellipse hebt strikte Verarbeitung auf


     association-definition    ::= < part [ , … ] >
     part                      ::= (ident | variable) ':' (ident | variable)




     topicmapslab.de
                                                                           27
Einführung in Topic Maps
Association-Definition
   %prefix m http://psi.ontopia.net/music/
   m:composed-by (
      m:composer : http://en.wikipedia.net/wiki/Puccini )


      → liefert alle Assoziationen, welche
            ●   vom Typ „komponiert“ ist
            ●   exakt eine Rolle vom Typ „Komponist“ gespielt von
                Puccini besitzt


  topicmapslab.de
                                                                    28
Einführung in Topic Maps
Association-Definition
   %prefix m http://psi.ontopia.net/music/
   m:composed-by (
      tm:subject : http://en.wikipedia.net/wiki/Puccini , … )


      → liefert alle Assoziationen, welche
            ●   vom Typ „komponiert“ ist
            ●   mindestens eine Rolle gespielt von Puccini besitzt
                → der Rollentyp ist nicht eingeschränkt


  topicmapslab.de
                                                                     29
Einführung in Topic Maps
Merge Expression
   %prefix m http://psi.ontopia.net/music/
   MERGE m:composed-by (
      tm:subject : http://en.wikipedia.net/wiki/Puccini , … )


      → verschmelzen aller Assoziationen vom Typ „komponiert“,
      welche von Puccini gespielt werden




  topicmapslab.de
                                                                 30
Einführung in Topic Maps
Merge Expression
 ●   Bedingungen
      ●   selber Typ
      ●   selber Scope


 ●   Funktionsweise:
      ●   Alle nicht vorhandenen Rollen werden kopiert
      ●   Quell-Assoziation wird gelöscht
      ●   Reifier werden verschmolzen


     topicmapslab.de
                                                         31
Einführung in Topic Maps




                       ENDE




 topicmapslab.de

Weitere ähnliche Inhalte

Mehr von Lutz Maicher

Semantische Technologien für kleine und mittlere Unternehmen
Semantische Technologien für kleine und mittlere UnternehmenSemantische Technologien für kleine und mittlere Unternehmen
Semantische Technologien für kleine und mittlere UnternehmenLutz Maicher
 
TMQL tutorial - part 6
TMQL tutorial - part 6TMQL tutorial - part 6
TMQL tutorial - part 6Lutz Maicher
 
TMQL tutorial - part 4
TMQL tutorial - part 4TMQL tutorial - part 4
TMQL tutorial - part 4Lutz Maicher
 
Topic Maps In The eHumanities
Topic Maps In The eHumanitiesTopic Maps In The eHumanities
Topic Maps In The eHumanitiesLutz Maicher
 
Medieninformatik und Topic Maps
Medieninformatik und Topic MapsMedieninformatik und Topic Maps
Medieninformatik und Topic MapsLutz Maicher
 
The Impact Of Semantic Handshakes
The Impact Of Semantic HandshakesThe Impact Of Semantic Handshakes
The Impact Of Semantic HandshakesLutz Maicher
 
Topic Maps Portals
Topic Maps PortalsTopic Maps Portals
Topic Maps PortalsLutz Maicher
 
Argumentation Trails and Topic Maps
Argumentation Trails and Topic MapsArgumentation Trails and Topic Maps
Argumentation Trails and Topic MapsLutz Maicher
 
Tutorial Introduction to Topic Maps
Tutorial Introduction to Topic MapsTutorial Introduction to Topic Maps
Tutorial Introduction to Topic MapsLutz Maicher
 
Topic Maps Lab and its portal at the Topic Maps User Conference 2009
Topic Maps Lab and its portal at the Topic Maps User Conference 2009Topic Maps Lab and its portal at the Topic Maps User Conference 2009
Topic Maps Lab and its portal at the Topic Maps User Conference 2009Lutz Maicher
 
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...Lutz Maicher
 
Einführung in Musica migrans
Einführung in Musica migransEinführung in Musica migrans
Einführung in Musica migransLutz Maicher
 
Dissertationsverteidigung "Autonome Topic Maps"
Dissertationsverteidigung "Autonome Topic Maps"Dissertationsverteidigung "Autonome Topic Maps"
Dissertationsverteidigung "Autonome Topic Maps"Lutz Maicher
 

Mehr von Lutz Maicher (15)

Semantische Technologien für kleine und mittlere Unternehmen
Semantische Technologien für kleine und mittlere UnternehmenSemantische Technologien für kleine und mittlere Unternehmen
Semantische Technologien für kleine und mittlere Unternehmen
 
TMQL tutorial - part 6
TMQL tutorial - part 6TMQL tutorial - part 6
TMQL tutorial - part 6
 
TMQL tutorial - part 4
TMQL tutorial - part 4TMQL tutorial - part 4
TMQL tutorial - part 4
 
Maiana
MaianaMaiana
Maiana
 
Topic Maps In The eHumanities
Topic Maps In The eHumanitiesTopic Maps In The eHumanities
Topic Maps In The eHumanities
 
Musica migrans
Musica migransMusica migrans
Musica migrans
 
Medieninformatik und Topic Maps
Medieninformatik und Topic MapsMedieninformatik und Topic Maps
Medieninformatik und Topic Maps
 
The Impact Of Semantic Handshakes
The Impact Of Semantic HandshakesThe Impact Of Semantic Handshakes
The Impact Of Semantic Handshakes
 
Topic Maps Portals
Topic Maps PortalsTopic Maps Portals
Topic Maps Portals
 
Argumentation Trails and Topic Maps
Argumentation Trails and Topic MapsArgumentation Trails and Topic Maps
Argumentation Trails and Topic Maps
 
Tutorial Introduction to Topic Maps
Tutorial Introduction to Topic MapsTutorial Introduction to Topic Maps
Tutorial Introduction to Topic Maps
 
Topic Maps Lab and its portal at the Topic Maps User Conference 2009
Topic Maps Lab and its portal at the Topic Maps User Conference 2009Topic Maps Lab and its portal at the Topic Maps User Conference 2009
Topic Maps Lab and its portal at the Topic Maps User Conference 2009
 
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...
Musica migrans - Topic Maps portal about the migration paths of Eastern Europ...
 
Einführung in Musica migrans
Einführung in Musica migransEinführung in Musica migrans
Einführung in Musica migrans
 
Dissertationsverteidigung "Autonome Topic Maps"
Dissertationsverteidigung "Autonome Topic Maps"Dissertationsverteidigung "Autonome Topic Maps"
Dissertationsverteidigung "Autonome Topic Maps"
 

TMQL tutorial - part 7

  • 1. Einführung in Topic Maps Topic Maps Query Language Session 7 Sven Krosse M. Sc. Topic Maps Lab an der Universität Leipzig krosse@informatik.uni-leipzig.de topicmapslab.de
  • 2. Einführung in Topic Maps Review – Session 6 1. FLW(O)R Style ● RETURN-Clause ● WHERE-Clause ● ORDER-BY Clause ● FOR-Clause 2. Verschachtelung 3. Content Types ● XML ● CTM topicmapslab.de
  • 3. Einführung in Topic Maps Agenda Useful TMQL Expression 1. If-Then-Else TMQL Part II 1. Delete Expression 2. Insert Expression 3. Merge Expression topicmapslab.de
  • 4. Einführung in Topic Maps Sprachbestandteile Useful Expression topicmapslab.de
  • 5. Einführung in Topic Maps Bedingte Anweisung ● bedingte Auswertung von Ergebnissen ● erlaubt bedingte Verzweigung zur Verarbeitungszeit ● Grammatik content ::= if path-expression then content [ else content ] topicmapslab.de 5
  • 6. Einführung in Topic Maps Bedingte Anweisung ● Pfadausdruck nach Schlüsselwort IF bestimmt Verzweigung ● leere Menge → ELSE-Zweig ● ELSE-Zweig ist optional → leere Menge bei fehlender Definition topicmapslab.de 6
  • 7. Einführung in Topic Maps Bedingte Anweisung %prefix o http://psi.ontopia.net/music/ FOR $topic IN // tm:subject RETURN IF $topic ISA o:composer THEN $topic >> indicators ELSE $topic / tm:name [0] topicmapslab.de 7
  • 8. Einführung in Topic Maps Bedingte Anweisung NCL ● Kurzform für bedingte Anweisung ● Bedingung repräsentiert „Then“-Zweig ● Grammatik content ::= path-expression || path-expression topicmapslab.de 8
  • 9. Einführung in Topic Maps Bedingte Anweisung NCL %prefix o http://psi.ontopia.net/music/ FOR $topic IN // tm:subject RETURN $topic >> indicators >> atomify [0] || $topic >> locators >> atomify [0] topicmapslab.de 9
  • 10. Einführung in Topic Maps TMQL – Part II topicmapslab.de
  • 11. Einführung in Topic Maps TMQL Part II ● kein ISO-Standard oder Draft ● basiert auf TMQL Part I ( TMQL – Query Language ) ● basiert syntaktisch auf dem Draft 2007 topicmapslab.de 11
  • 12. Einführung in Topic Maps TMQL Part II ● definiert Veränderungsoperationen für Topic Maps ● Einfügeoperation ● Löschoperation ● Änderungsoperation ● Merge-Regeln topicmapslab.de 12
  • 13. Einführung in Topic Maps Sprachbestandteile Insert Expression topicmapslab.de
  • 14. Einführung in Topic Maps Insert Expression ● Erzeugen neuer Topic Maps Konstrukte ● Verwendung von CTM als Definitionssprache ● CTM-Content äquivalent zu FLW(O)R Style ● Verwendung von Variablen (gebunden durch Where-Klausel) ● erlaubt auch Änderung bestehender Elemente topicmapslab.de 14
  • 15. Einführung in Topic Maps Insert Expression ● Grammatik insert-expression ::= INSERT “““ctm-stream “““ { WHERE query-expression } topicmapslab.de 15
  • 16. Einführung in Topic Maps Insert Expression INSERT “““ <http://psi.example.org/topic>. “““ → Fügt ein neues Topic mit dem Subject-Identifier hinzu INSERT “““ { $topic >> indicators >> atomify [0] ISA <http://psi.example.org/topic> . } “““ WHERE $topic ISA tm:subject → Fügt jedem Topic den Typ http://psi.example.org/topic hinzu topicmapslab.de 16
  • 17. Einführung in Topic Maps Sprachbestandteile Delete Expression topicmapslab.de
  • 18. Einführung in Topic Maps Delete Expression ● Entfernen bestehender Topic Maps Konstrukte ● Adressierung von Konstrukten über Pfadausdruck ● Abhängigkeit werden nicht automatisch entfernt (z.B. Topic als Reifier, Topic als Typ) topicmapslab.de 18
  • 19. Einführung in Topic Maps Delete Expression ● direkte Adressierung über Pfadausdruck und Filter ● Grammatik delete-expression ::= DELETE { CASCADE } simple-content {filter-postfix} WHERE boolean-expression ● Schlüsselwort CASCADE definiert Löschen aller Abhängigkeiten ● nicht kaskadiert ( Löschen wird abgebrochen ) ● Where-Klausel definiert Wertebereich der Variablen topicmapslab.de 19
  • 20. Einführung in Topic Maps Delete Expression DELETE CASCADE http://en.wikipedia.org/wiki/Puccini → entfernt das Topic Puccini und alle seine Abhängigkeiten – gespielte Rollen und Assoziation – alle Namen und Occurrences – Verwendung als Theme (Konstrukte werden gelöscht) – Verwendung als Reifier (Reifikation wird aufgehoben) topicmapslab.de 20
  • 21. Einführung in Topic Maps Delete Expression DELETE CASCADE http://psi.ontopia.net/music/composer >> instances → entfernt alle Komponisten aus der Topic Map DELETE CASCADE ALL → entfernt jegliche Konstrukte aus der Topic Map topicmapslab.de 21
  • 22. Einführung in Topic Maps Sprachbestandteile Merge Expression topicmapslab.de
  • 23. Einführung in Topic Maps Merge Expression ● Mergen von Topics gemäß TMDM ● Definition einer Menge von Topics, welche gemergt werden sollen ● Verwendung von Variablen ● Where-Klausel schränkt Wertebereich der Variablen ein ● Grammatik merge-expression ::= MERGE <value-expression> WHERE boolean-expression topicmapslab.de 23
  • 24. Einführung in Topic Maps Merge Expression MERGE // http://psi.example.org/type [ . / email == „person@gmail.com“ ] → alle Topics, welche die folgenden Bedingung erfüllen, werden gemergt ● Instanz vom Typ http://psi.example.org/type ● besitzen mindestens eine Occurrence vom Typ email ● Wert mindestens einer dieser Occurrence ist person@gmail.com topicmapslab.de 24
  • 25. Einführung in Topic Maps Merge Expression MERGE $person, $other WHERE $person ISA person AND $other ISA person AND $person / email == $other / email → Personen mit der selben E-Mail Adresse werden gemergt topicmapslab.de 25
  • 26. Einführung in Topic Maps Merge Expression ● Mergen von Assoziation ● Definition einer Menge von Assoziation, welche verschmelzen sollen ● Grammatik merge-expression ::= MERGE association-definition WHERE boolean-expression topicmapslab.de 26
  • 27. Einführung in Topic Maps Association-Definition ● äquivalent zu Predicate-Invocation (eingeschränkte Syntax) ● liefern Menge von Assoziation passend zum definierten Muster ● Ellipse hebt strikte Verarbeitung auf association-definition ::= < part [ , … ] > part ::= (ident | variable) ':' (ident | variable) topicmapslab.de 27
  • 28. Einführung in Topic Maps Association-Definition %prefix m http://psi.ontopia.net/music/ m:composed-by ( m:composer : http://en.wikipedia.net/wiki/Puccini ) → liefert alle Assoziationen, welche ● vom Typ „komponiert“ ist ● exakt eine Rolle vom Typ „Komponist“ gespielt von Puccini besitzt topicmapslab.de 28
  • 29. Einführung in Topic Maps Association-Definition %prefix m http://psi.ontopia.net/music/ m:composed-by ( tm:subject : http://en.wikipedia.net/wiki/Puccini , … ) → liefert alle Assoziationen, welche ● vom Typ „komponiert“ ist ● mindestens eine Rolle gespielt von Puccini besitzt → der Rollentyp ist nicht eingeschränkt topicmapslab.de 29
  • 30. Einführung in Topic Maps Merge Expression %prefix m http://psi.ontopia.net/music/ MERGE m:composed-by ( tm:subject : http://en.wikipedia.net/wiki/Puccini , … ) → verschmelzen aller Assoziationen vom Typ „komponiert“, welche von Puccini gespielt werden topicmapslab.de 30
  • 31. Einführung in Topic Maps Merge Expression ● Bedingungen ● selber Typ ● selber Scope ● Funktionsweise: ● Alle nicht vorhandenen Rollen werden kopiert ● Quell-Assoziation wird gelöscht ● Reifier werden verschmolzen topicmapslab.de 31
  • 32. Einführung in Topic Maps ENDE topicmapslab.de