[topicmapmail] RE: Can you help with XTMSerializer ??
Dicheva, Darina
dichevad at wssu.edu
Thu Nov 2 10:22:20 EST 2006
Hi Stefan,
I thought this discussion (including my previous problems & solutions :-) might be useful for others who decide to migrate from TM4J to TMAPI, so I am CC-ing it to the topicmail list (I am not sure whether the TMAPI list functions).
> For searching a topicname why not use the TMAPi index API
> http://tmapi.org/index.gif
I do use org.tmapi.index in my utility methods, but I cannot see an index method that can directly return the name of a topic within a scope, e.g. the unconstrained scope - I presume that this is the 'primary topic name' that the user uses as a topic label. I am using the following method:
public static String getTopicDisplayName(Topic t, TopicMap tm)
throws Exception {
boolean nameFound = false;
String name = "[no name]";
Iterator ni = t.getTopicNames().iterator();
while (ni.hasNext() && !nameFound) {
TopicName n = (TopicName) ni.next();
Collection scope = n.getScope();
// if scope empty - name is unconstrained
if (n.getScope().isEmpty()) {
name = n.getValue();
nameFound = true;
}
}
return name;
}
Is there a more direct way?
> Btw. Which TMAPI implementation are you using,? My tinyTIM or
> the old tm4j?
I am using tm4j since I am familiar with it.
Thanks,
Darina
> > -----Ursprüngliche Nachricht-----
> > Von: Dicheva, Darina [mailto:dichevad at wssu.edu]
> > Gesendet: Donnerstag, 2. November 2006 04:23
> > An: Stefan Lischke
> > Betreff: RE: Can you help with XTMSerializer ??
> >
> > Hi Stefan,
> >
> > Thanks for asking :-) Well, the next one wasn't easy either.
> > I was getting a Java null pointer exception in my
> > createNewTopic method at t.createTopicName(topicName, null);
> > /which of course used to work perfectly before with TM4J/ I
> > noticed though that I only was getting it after saving the
> > file when trying to re-create my utility topics (which I
> > delete before saving the file). It took me a while to
> > discover that it was related to the TM4J attempt for topic
> > merging and I needed to include
> >
> > tmfac.setFeature("http://tmapi.org/features/merge/byTopicName",
> > false);
> >
> > This fixed that problem. The Editor seems to work now, but I
> > haven't checked all its functions thoroughly. It will take
> a while :-)
> >
> > One thing that I am not sure if I am doing efficiently is
> > finding topics' 'display' names. In TM4J I used
> >
> > String topicName = (String)m_nameExtractor.fn(topic);
> >
> > but in TMAPI I didn't find a similar thing. So I just walk
> > through the topic names and extract the first name within the
> > unconstrained scope. I am not sure should I forbid adding a
> > second name in the unconstrained scope ...
> >
> > Anyway, I appreciate a lot your willigness to help and if you
> > don't mind will take an advantage of it when face some more
> > serious /for me/ problem in this transition to TMAPI :-)
> >
> > All the very best,
> > Darina
> >
> > > -----Original Message-----
> > > From: Stefan Lischke [mailto:lischke at novacom.net]
> > > Sent: Wednesday, November 01, 2006 10:34 AM
> > > To: Dicheva, Darina
> > > Subject: AW: Can you help with XTMSerializer ??
> > >
> > > Hi,
> > >
> > > What are the other errors ;-)
> > >
> > > > -----Ursprüngliche Nachricht-----
> > > > Von: Dicheva, Darina [mailto:dichevad at wssu.edu]
> > > > Gesendet: Dienstag, 31. Oktober 2006 19:09
> > > > An: Stefan Lischke
> > > > Betreff: RE: Can you help with XTMSerializer ??
> > > >
> > > > Stefan,
> > > >
> > > > Thanks a lot for your willigness to help. In fact I solved this
> > > > problem - I found that that kind of error could be due to
> > compiling
> > > > and running against different version of classes/jars and
> > replaced
> > > > the TM4J version that I used with the latest one and now the
> > > > Serializer behaves properly :-) I am continuing with the other
> > > > errors :-)
> > > >
> > > > Thanks again!
> > > > Darina
> > > >
> > > >
> > > >
> > > > > -----Original Message-----
> > > > > From: Stefan Lischke [mailto:lischke at novacom.net]
> > > > > Sent: Tuesday, October 31, 2006 5:50 AM
> > > > > To: Dicheva, Darina
> > > > > Subject: AW: Can you help with XTMSerializer ??
> > > > >
> > > > > Hi Darina,
> > > > >
> > > > > I want to help you, but can you send me the XTM, you
> > > parse and then
> > > > > write?
> > > > > Ist difficult for me to understand your problem, by not
> > > > knowing what
> > > > > you want to serialise... Any way to reproduce it?
> > > > >
> > > > > Thanx in advance
> > > > >
> > > > > stefan
> > > > >
> > > > > > -----Ursprüngliche Nachricht-----
> > > > > > Von: Dicheva, Darina [mailto:dichevad at wssu.edu]
> > > > > > Gesendet: Montag, 30. Oktober 2006 17:22
> > > > > > An: Stefan Lischke; Stefan Lischke
> > > > > > Betreff: Can you help with XTMSerializer ??
> > > > > >
> > > > > > Hi Stefan,
> > > > > >
> > > > > > I am working on migrating TM4L from TM4J to TMAPI and I
> > > > am using the
> > > > > > TMAPI utilities for input/output. I don't have a problem
> > > > with your
> > > > > > parser, but when I try to save a file I get the error
> > > > message below
> > > > > > from the Serializer. I am using the following to save a
> > > > topic map to
> > > > > > a file:
> > > > > >
> > > > > > public static void writeToXTM(Writer w, TopicMap tm)
> > > > > > throws Exception {
> > > > > > try{
> > > > > > XTMSerializer xtmS = new XTMSerializer();
> > > > > > xtmS.serialize(w, tm);
> > > > > > }catch(TMAPIException e){
> > > > > > e.printStackTrace();
> > > > > > }
> > > > > > }
> > > > > >
> > > > > > Any idea what's happening?
> > > > > >
> > > > > > Thanks,
> > > > > > Darina
> > > > > >
> > > > > > ---
> > > > > >
> > > > > > Exception in thread "AWT-EventQueue-0"
> > > > > java.lang.AbstractMethodError:
> > > > > >
> > > > >
> > > >
> > >
> >
> org.tm4j.tmapi.core.TMAPITopicImpl.getSubjectLocators()Ljava/util/Set;
> > > > > > at
> > > > > >
> org.tmapiutils.impexp.xtm.XTMSerializer.writeTopic(XTMSerializ
> > > > > > er.java:20
> > > > > > 5)
> > > > > > at
> > > > > >
> org.tmapiutils.impexp.xtm.XTMSerializer.writeTopic(XTMSerializ
> > > > > > er.java:18
> > > > > > 1)
> > > > > > at
> > > > > >
> org.tmapiutils.impexp.xtm.XTMSerializer.serialize(XTMSerialize
> > > > > > r.java:74)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> tm4l.utilities.utilitiesTM.UTopicMaps.writeToXTM(UTopicMaps.java:313)
> > > > > > at
> > > > > >
> tm4l.utilities.utilitiesTM.UTopicMaps.writeTopicMapToXTM(UTopi
> > > > > > cMaps.java
> > > > > > :297)
> > > > > > at
> > > tm4l.ui.TM4LMenuActions.saveTM(TM4LMenuActions.java:205)
> > > > > > at
> > > tm4l.ui.TM4LMenubar$4.actionPerformed(TM4LMenubar.java:133)
> > > > > > at
> > > > > >
> javax.swing.AbstractButton.fireActionPerformed(AbstractButton.
> > > > > > java:1849)
> > > > > > at
> > > > > >
> javax.swing.AbstractButton$Handler.actionPerformed(AbstractBut
> > > > > > ton.java:2
> > > > > > 169)
> > > > > > at
> > > > > >
> javax.swing.DefaultButtonModel.fireActionPerformed(DefaultButt
> > > > > > onModel.ja
> > > > > > va:420)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> javax.swing.DefaultButtonModel.setPressed(DefaultButtonModel.java:258)
> > > > > > at
> > > javax.swing.AbstractButton.doClick(AbstractButton.java:302)
> > > > > > at
> > > > > >
> javax.swing.plaf.basic.BasicMenuItemUI.doClick(BasicMenuItemUI
> > > > > > .java:1000
> > > > > > )
> > > > > > at
> > > > > >
> javax.swing.plaf.basic.BasicMenuItemUI$Handler.mouseReleased(B
> > > > > > asicMenuIt
> > > > > > emUI.java:1041)
> > > > > > at
> > > java.awt.Component.processMouseEvent(Component.java:5488)
> > > > > > at
> > > > > >
> javax.swing.JComponent.processMouseEvent(JComponent.java:3093)
> > > > > > at java.awt.Component.processEvent(Component.java:5253)
> > > > > > at java.awt.Container.processEvent(Container.java:1966)
> > > > > > at
> > > java.awt.Component.dispatchEventImpl(Component.java:3955)
> > > > > > at
> > > java.awt.Container.dispatchEventImpl(Container.java:2024)
> > > > > > at java.awt.Component.dispatchEvent(Component.java:3803)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> java.awt.LightweightDispatcher.retargetMouseEvent(Container.java:4212)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> java.awt.LightweightDispatcher.processMouseEvent(Container.java:3892)
> > > > > > at
> > > > > >
> > > java.awt.LightweightDispatcher.dispatchEvent(Container.java:3822)
> > > > > > at
> > > java.awt.Container.dispatchEventImpl(Container.java:2010)
> > > > > > at java.awt.Window.dispatchEventImpl(Window.java:1766)
> > > > > > at java.awt.Component.dispatchEvent(Component.java:3803)
> > > > > > at
> > > java.awt.EventQueue.dispatchEvent(EventQueue.java:463)
> > > > > > at
> > > > > >
> java.awt.EventDispatchThread.pumpOneEventForHierarchy(EventDis
> > > > > > patchThrea
> > > > > > d.java:234)
> > > > > > at
> > > > > >
> java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispa
> > > > > > tchThread.
> > > > > > java:163)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:157)
> > > > > > at
> > > > > >
> > > > >
> > > >
> > >
> >
> java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:149)
> > > > > > at
> > > > > >
> java.awt.EventDispatchThread.run(EventDispatchThread.java:110)
> > > > >
> > > > >
> > >
> > >
>
>
More information about the topicmapmail
mailing list