From: Richard W. <rw...@cs...> - 2001-06-19 14:24:31
|
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 :) |