From: Kal A. <ka...@te...> - 2001-06-19 16:25:15
|
Hi Rich, > > You're right in that it's merging. :) I'm not sure why, though... > Tracked it down - the subjectIndicatorRef was the culprit after all! When the XTMBuilder sees the subjectIndicatorRef, it tries to locate a topic with that subject indicator and creates it if it doesn't exist - the upshot is that your topic then gets merged with that dummy topic that was created. The fix to this is in XTMBuilder.java, line 294(ish). change: case REFTYPE_SUBJECTINDICATOR: refTopic = getTopicBySubjectIndicator(expandedRef); break; to case REFTYPE_SUBJECTINDICATOR: if (purpose != SUBJECTIDENTITY) { refTopic = getTopicBySubjectIndicator(expandedRef); } break; I'm currently away from my Linux machine and can't seem to check this change in from my (Windoze) laptop (grrr....), but hopefully this should fix your problem. Cheers, Kal > This is the entire TM: > > <?xml version="1.0" encoding="utf-8" standalone="yes" ?> > <topicMap xmlns="http://www.topicmaps.org/xtm/1.0/" > xmlns:xlink="http://www.w3.org/1999/xlink" > xml:base="http://ideabank.csir.co.za/test2.xml"> > > <topic id="kim"> > <baseName> > <baseNameString>Kim</baseNameString> > </baseName> > > <instanceOf> > <topicRef > xlink:href="http://ideabank.csir.co.za/ib.defs.xml#person"/> > </instanceOf> > <subjectIdentity> > <subjectIndicatorRef > xlink:href="http://ideabank.csir.co.za/data#role"/> > </subjectIdentity> > </topic> > </topicMap> > > And I'm loading it by itself. The subjectIdentityRef is a red herring > (sorry :), I only used that as an example. > > But that still helps a lot so far, thanks :) > Rich > > > -----Original Message----- > > From: tm4...@li... > > [mailto:tm4...@li...]On Behalf Of Kal Ahmed > > Sent: 19 June 2001 04:40 > > To: tm4...@li... > > Subject: RE: [TM4J-users] loading problem > > > > > > Hi Rich, > > > > I think that it is possible that the topic is getting merged with > > some other > > topic. In your example, you have > > > > <topic id="kim"> > > <baseName> > > <baseNameString>Kim</baseNameString> > > </baseName> > > > > <instanceOf> > > <topicRef > > xlink:href="http://ideabank.csir.co.za/ib.defs.xml#person"/> > > </instanceOf> > > <subjectIdentity> > > <subjectIndicatorRef > > xlink:href="http://ideabank.csir.co.za/data#role"/> > > </subjectIdentity> > > </topic> > > > > This would get merged with any topic which has the same > > subjectIndicatorRef - I am just guessing from the URL of the > > subjectIndicatorRef, that it is not meant to be unique to Kim. > > > > The TopicMap.getTopics() returns all of the base topics - any > > merged topics > > are not included in the returned collection. Perhaps there should be a > > TopicMap.getAllTopics() function that includes the merged > topics in there. > > As a test, when you iterate through the collection, also call > > Topic.getMergedTopics() and iterate through that - my hunch is > that Kim is > > lurking in there somewhere :-) > > > > Cheers, > > > > Kal > > > > > -----Original Message----- > > > From: tm4...@li... > > > [mailto:tm4...@li...]On Behalf Of Richard > > > Watson > > > Sent: 19 June 2001 15:24 > > > To: TM4J Users > > > Subject: [TM4J-users] loading problem > > > > > > > > > Hi all, > > > > > > Got an interesting one. Java code that produces a strange result > > > as soon as > > > a subjectIdentity is added to a topic. > > > > > > Java code: > > > > > > (obviously uses some of my own stuff, but you'll get the idea) > > > > > > // largely irrelevant but just so you know :) > > > PersistenceManager p = PersistenceManager.getPersistenceManager(); > > > String strObject = "http://ideabank.csir.co.za/test2.xml#kim"; > > > TopicMap tm = p.getTopicMapForURL(new URL(strObject)); > > > > > > // here's the interesting bit > > > Topic o = (Topic)tm.getObjectByResourceID(strObject); > > > System.out.println("object " + o); > > > System.out.println("contains object: " + tm.getTopics().contains(o)); > > > > > > which produces output: > > > object com.techquila.topicmap.TopicImpl@d3147aed > > > contains object: false > > > > > > from this xml: > > > > > > <topic id="kim"> > > > <baseName> > > > <baseNameString>Kim</baseNameString> > > > </baseName> > > > > > > <instanceOf> > > > <topicRef > > > xlink:href="http://ideabank.csir.co.za/ib.defs.xml#person"/> > > > </instanceOf> > > > <subjectIdentity> > > > <subjectIndicatorRef > > > xlink:href="http://ideabank.csir.co.za/data#role"/> > > > </subjectIdentity> > > > </topic> > > > > > > and this output: > > > > > > object com.techquila.topicmap.TopicImpl@e79ef0b9 > > > contains object: true > > > > > > <topic id="kim"> > > > <baseName> > > > <baseNameString>Kim</baseNameString> > > > </baseName> > > > > > > <instanceOf> > > > <topicRef > > > xlink:href="http://ideabank.csir.co.za/ib.defs.xml#person"/> > > > </instanceOf> > > > </topic> > > > > > > I've round-tripped it as best I could, and it spits out: > > > > > > <topic> > > > <instanceOf> > > > <topicRef > > > xlink:href="http://ideabank.csir.co.za/ib.defs.xml#person"/> > > > </instanceOf> > > > <subjectIdentity> > > > <subjectIndicatorRef > > > xlink:href="http://ideabank.csir.co.za/data#role"/> > > > </subjectIdentity> > > > <baseName> > > > <baseNameString>Kim</baseNameString> > > > </baseName> > > > </topic> > > > > > > (observe the removed topic id) > > > This works fine for the first version (i.e. keeps the id). > > > > > > Also, while iterating through the topics, I find no resourceid > > for "kim". > > > But if I print out the o.resourceID above, I get the right one. > > > > > > So: iterating through the topics _does_ find a topic with the right > > > information but the wrong resourceID, and using > > tm.getObjectByResourceID() > > > finds a topic with the right resourceid. > > > > > > Cheers, > > > Rich the bug hunter :) > > > > > > > > > _______________________________________________ > > > Tm4j-users mailing list > > > Tm4...@li... > > > http://lists.sourceforge.net/lists/listinfo/tm4j-users > > > > > > > > > _______________________________________________ > > Tm4j-users mailing list > > Tm4...@li... > > http://lists.sourceforge.net/lists/listinfo/tm4j-users > > > > > _______________________________________________ > Tm4j-users mailing list > Tm4...@li... > http://lists.sourceforge.net/lists/listinfo/tm4j-users > > |