[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Subject: Re: [topicmaps-comment] mapping topic maps on a relation database
[Lars Marius Garshol] > > * Thomas B. Passin > | > | Oh, good, you've got something going on an API. Wish I had known... > | We had a thread on this some months ago and it didn't seem like it > | was going anywhere. > > Actually, it's been around for a while. It hasn't really been > announced, though. I know Kal was planning to do this at some point, > so I hope I haven't stolen his thunder now. > > | I won't have time to contribute until late summer at least, I'm > | sorry to say, but I'd be glad to let you see the object API I use > | with my javascript engine. It could easily be translated to Python > | or java. This API is targeted towards end applications like > | browsers. Let me know if you would be interested. > > I would definitely be interested. > Lars has (off-line) asked me to make this API publicly available. I agreed, so here it is in the attachment. I have found that this set of APIs is very practical for the applications I have built so far. In fact, I developed it so I could experiment with UIs for topic maps. In addition to the core API I have attached, I have a bunch of utility functions, but I don't know that they belong in the API per se, and haven't included them. I won't pretend that this API is complete, but it has been a great help to me in exploring UI issues for topic maps. With the help of utility functions, you can save maps in a javascript or xtm format, load the apps using a javascript serialization (which you can get from an xtm map using an xslt stylesheet), filter by scopes, and a wide range of other useful things. It probably has about 80% of the features needed for general apps. Porting this API to Python from javascript is almost a no-brainer. I did it in one long evening. For java, since I use multiple inheritance, you would want to make the abstract classes pure interfaces instead. Then you could implement the multiple interfaces where I'm using multiple inheritance. What's that, you say? Javascript does not have multiple inheritance? Well, it turns out you can simulate multiple inheritance. Javascript doesn't really have inheritance anyway, it uses prototypes in a way almost exactly the same way as Python. Python actually makes a good prototyping language for javascript, although in this case I've done it the other way round. Enjoy! Tom P
// Tom Passin's Javascript Topic Map API // 4-20-2002 Thomas B. Passin // Abstract classes - should probably just be interfaces bareTopic(id) // Sets instanceOf to "tt-urtype" (universal type). scopedObject() // Contains a list of scoping topic (ids) getScopes() // returns list of scopes addScope(scope) /* The next three methods accept a list of scope ids. they return boolean true or false */ hasScope(filters) // Currently the same as hasScopeOr() hasScopeOr(filters) // Return true of object is scoped by any scope in filters hasScopeAnd(filters) // Return true of object is scoped by all scopes in filters scopedTopic(id) // Inherits from bareTopic and scopedTopic // Has no other methods or properties // topic class - inherits from bareTopic // Currently, instanceOf values are get/set as properties, but there should be // methods for this topic(id) addBaseName(name) // name is a string addOccur(Occur) // Occur is an occurrence object // "filters" is a list of filter topic ids getNamesFiltered(filters) getNamesFilteredAny(filters) getOccursFiltered(filters) erase() // Delete all components of a topic so it can be deleted setIdentity(subject_identity) getIdentity() // baseName Class baseName(label) getNameString() // set by constructor or property assignment erase() // Occurrence class - inherits from scopedTopic occur(id) // id is optional // Currently resourceRef or resourceData are set by writing to the properties // (more Pythonic). Probably should use setter methods for general use. getResource() getData() getResourceOrData() erase() // Subject Identity class - this is not very developed yet, very crude subjectIdentity(id) // id is optional getResourceRef() getResourceUri() changeResourceRef(newuri) getTopicRefs() // returns a list getSubjectIndicators() // returns a list setResourceRef(resourceRefObject) setResourceRefUri(uri) addTopicRef(topicRefObject) addSubjectIndicatorRef(subjIndicatorRefObject) // Topic Map class topicMap(id) // id is optional addTopic() addAssoc() getTopics() // Returns a dictionary (hash) of topic objects keyed by id getTopicsFiltered(filters) // "filters" is a list of filter topic ids addScope(scope) // If we keep an index of scopes, use this to add a scope /* getTopicsFilteredAny(filters) returns a list of topics whose basenames are in one of the scope ids in "filters". Currently it is a little mixed up because if no filter is specified, the entire dictionary of topics is returned, but if there are any filtering topics, a list is returned. I need to decide how to make them consistent. */ getTopicsFilteredAny(filter) getTopicById(id) getTopicsByType(typeid) getAssocIndex() getAllScopes() // Return a list of all topics used as scopes // (so they can be listed in a GUI) getNameScopes() // A list of all scopes used for scoping baseNames getAssocScopes() // A list of all scopes used for scoping associations getAssociations() // A dictionary of associations getAssociationsFilteredOr(filters) // A list of associations, but has same // inconsistency as getTOpicsFilteredAny() getAssociationsFilteredAnd(filters) getAssocByType(typeid) erase() // Delete all components of a topic map deleteTopicById(id) /* scope class. Each scope object references just one topic (actually the id of the topic). This is set/get as a property, but there should be methods for this */ scope(topicid) erase() // association class - inherits from scopedObject association(id) // id is optional addMember(member) // If a member if this type already exists, add // its role-players to the existing member instead getMembers() // Returns a list of member objects in the association getMemberByRoleType(typeid) getID() erase() // member class. Players are roleplaying topic objects. member(roleSpec) // Create and initialize member. "roleSpec" is a topic id. addPlayer(playerobject) getPlayers() // Return a list of role-playing topics erase() //
[Date Prev] | [Thread Prev] | [Thread Next] | [Date Next] -- [Date Index] | [Thread Index] | [Elist Home]
Powered by eList eXpress LLC