streaming topic maps api

24
Streaming Topic Maps API An event-based API to create topic maps Lars Heuer <[email protected]> TMRA 2008, Leipzig · 17.10.2008

Upload: tmra

Post on 21-Dec-2014

1.092 views

Category:

Technology


0 download

DESCRIPTION

This paper introduces a new, event-based API to create topic maps. It is independent of particular Topic Maps processors and enables developers to convert any resource into a Topic Maps representation with minimal e?ort. The API is somewhat aligned to the "push-model" of the familiar Simple API for XML (SAX) and is therefore easy to learn. It has been implemented for different programming languages and supplements APIs like the object-orientated Topic Maps API (TMAPI).

TRANSCRIPT

Page 1: Streaming Topic Maps API

StreamingTopic Maps API

An event-based API to createtopic maps

Lars Heuer <[email protected]>

TMRA 2008, Leipzig · 17.10.2008

Page 2: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 2

Table of Contents

IntroductionOverviewArchitectureDetailsOutlook

Page 3: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 3

IntroductionTMAPI is the Document Object Model (DOM) forTopic MapsEven if TMAPI is Topic Maps engine independent, a deserializer would be TMAPI dependentTMAPI is programming language dependent (even ifTMAPI has been ported to several languages)Relative heavy API (a lot of factory methods)Streaming Topic Maps API uses a push model(more aligned to the Simple API for XML (SAX))

Page 4: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 4

OverviewA parser notifies a handler about eventsIMapHandler interface provides notification methodsfor all TMDM facets:

startTopicMapendTopicMapstartTopicendTopicstartAssociationendAssociationstartReifierendReifier... (32 callback methods)

Page 5: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 5

Architecture

IMapHandler

CTM Parser XTM Parser N3 Parser CSV Parser … Parser

sends events to

Page 6: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 6

Architecture

IMapHandler

CTM Parser XTM Parser N3 Parser CSV Parser … Parser

TMAPI RDF API … API

sends events to

implemented by

N3 Parser

Page 7: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 7

Details – IMapHandler

Page 8: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 8

DetailsIMapHandler provides 32 callback methods to coverall aspects of TMDMEach TMDM construct is introduced by a "start" event and terminated by an "end" eventSubject identifiers, subject locators and itemidentifiers are reported as absolute IRIs (strings)IRefs are used for "startTopic(ref)" and "topicRef(ref)" notifications, they provide theabsolute IRI (string) and the kind of identityIMapHandler provides nested events (i.e. startTopicfollowed by another startTopic event) iff the eventscannot be misinterpreted

Page 9: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 9

Details

IMapHandler is reponsible to detect mergingsitutationsParser simply fires events and forgetsafterwardsIMapHandler usually keeps a stack of objects/ states to interpret the events correctlyEvents are sometimes context dependent, i.e. "start/endType", "start/endScope", "start/endReifier", …

Page 10: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 10

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

Page 11: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 11

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

startTopic(ItemIdentifier http://example.org/map#EricClapton)

Page 12: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 12

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

startName()

Page 13: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 13

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

value("Eric Clapton")

Page 14: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 14

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

endName()endTopic()

Page 15: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 15

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

startAssociation()startType()topicRef(ItemIdentifier http://example.org/map#created)endType()

Page 16: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 16

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

startRole()startType()topicRef(ItemIdentifier http://example.org/map#creator)endType()

Page 17: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 17

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

startPlayer()topicRef(ItemIdentifier http://example.org/map#EricClapton)endPlayer()endRole()

Page 18: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 18

Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,

work: JustOneNight)

endAssociation()

... other role

Page 19: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 19

Details – Stackability

IMapHandler

IMapHandler IMapHandler

Parser

delegates to

Page 20: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 20

Details – SimpleMapHanderParser has to send a lot of start/end eventsSome syntaxes do not provide nested topics etc.SimpleMapHandler is a wrapper around anyIMapHandler implementionSimpleMapHandler provides additional methods like"type(IRef ref)", "player(IRef ref)", "reifier(IRef ref)"…These events are translated to the commonIMapHandler callback methodsExample:player(IRef) startPlayer(), topicRef(IRef), endPlayer()Simplifies parser development

Page 21: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 21

Details – MIO Framework MIO (Map Input / Output) is built around theIMapHandler and provides a Service Provider Interface for registering IDeserializersAll IDeserializers use the IMapHandler for eventnotificationDiscovery of a suitable IDeserializer by fileextension, media typeIntroduces some constraints: I.e. a subdeserializer(i.e. merging XTM encoded topic map into a CTM encoding topic map) must not send a start/endTopicMap event

Page 22: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 22

Conclusions / OutlookSimplifies parser development because the parsersimply fires events and does not care about mergingconstraints etc.IMapHandler concept has been implemented in Java, Python (Mappa) and PHP (QuaaxTM)IMapHandler and MIO (Map Input/Output) will become Open Source soonStreaming Topic Maps API should be controlled / adapted by the community (i.e. by the TMAPI project)

Page 23: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 23

ReferencesTMAPIhttp://www.tmapi.org/TMAPI 2.0http://www.tmapi.org/2.0/tinyTiMTMAPI 1.0 / TMAPI 2.0 Topic Maps enginehttp://tinytim.sourceforge.net/MappaPython Topic Maps engine (not finished)http://mappa.googlecode.com/MIO (Map I/O)http://mio.semagia.com/QuaaxTMhttp://quaaxtm.sourceforge.net/

Page 24: Streaming Topic Maps API

© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 24

Discussion

Questions?

Answers! ☺