Download - Streaming Topic Maps API
StreamingTopic Maps API
An event-based API to createtopic maps
Lars Heuer <[email protected]>
TMRA 2008, Leipzig · 17.10.2008
© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 2
Table of Contents
IntroductionOverviewArchitectureDetailsOutlook
© 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))
© 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)
© 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
© 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
© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 7
Details – IMapHandler
© 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
© 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", …
© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 10
Details – Parsing ExampleEricClapton – "Eric Clapton".created(creator: EricClapton,
work: JustOneNight)
© 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)
© 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()
© 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")
© 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()
© 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()
© 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()
© 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()
© 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
© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 19
Details – Stackability
IMapHandler
IMapHandler IMapHandler
Parser
delegates to
© 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
© 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
© 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)
© 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/
© 2008 Lars Heuer · http://www.semagia.com TMRA 2008, Leipzig · 17.10.2008 24
Discussion
Questions?
Answers! ☺