kozchris / tmapix

Automatically exported from code.google.com/p/tmapix
0 stars 0 forks source link

XTM20Reader creates unnecessary item identifier #12

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
Try the following Unit test:

TopicMap tm = 
TopicMapSystemFactory.newInstance().newTopicMapSystem().createTopicMap("http://t
est.de");

String si = "http://psi.test.de/testtopic1";

Locator siLocator = tm.createLocator(si);

Topic t = tm.createTopicBySubjectIdentifier(siLocator);
assertEquals(0, t.getItemIdentifiers().size());

// store topic map
File testFile = new File("/tmp/test.xtm");
XTM20TopicMapWriter writer = new XTM20TopicMapWriter(new 
FileOutputStream(testFile),
        "http://psi.test.de/baselocator/");

writer.write(tm);

// reload topicmap
tm = 
TopicMapSystemFactory.newInstance().newTopicMapSystem().createTopicMap("http://t
est2.de");

XTM20TopicMapReader reader = new XTM20TopicMapReader(tm, testFile);
reader.read();

t = tm.getTopicBySubjectIdentifier(siLocator);
assertNotNull(t);
assertEquals(0, t.getItemIdentifiers().size());

What is the expected output? What do you see instead?
I expected that the topic t is in the same state as before the serialization.
If you write/read a topic map often you get many item identifiers for the topic 
which are not needed.

Original issue reported on code.google.com by h.niederhausen@googlemail.com on 31 Mar 2010 at 1:01

GoogleCodeExporter commented 8 years ago
The additional item identifier *is necessary* since XTM 2.0 mandates a topic
identifier for each topic <topic id="bla"/>.

If you serialize the topic map again (with the same document locator) you 
shouldn't
see more item identifiers since the writer will reuse existing item identifiers 
to
avoid the generation of additional item identifiers.

The XTM 2.1 writer may rescue you, though (will be added in the next couple of 
days).

Original comment by lars.he...@gmail.com on 31 Mar 2010 at 1:10

GoogleCodeExporter commented 8 years ago
(the *reader* does not create additional item identifiers, the writer does)

Original comment by lars.he...@gmail.com on 31 Mar 2010 at 1:23

GoogleCodeExporter commented 8 years ago
But why can't I see them in the written xtm file?
Only after writing after rereading the toipic map an item identifier is 
serialized.

The following is the file created by this test:
<topicMap xmlns="http://www.topicmaps.org/xtm/" version="2.0"><topic id="id-
2"><subjectIdentifier href="http://psi.test.de/testtopic1"/></topic></topicMap

Original comment by h.niederhausen@googlemail.com on 31 Mar 2010 at 1:29

GoogleCodeExporter commented 8 years ago
"id-2" is the item identifier. I guess you're looking for "itemIdentity" right? 

The topic id is converted into an item identifier during deserialization. 

Original comment by lars.he...@gmail.com on 31 Mar 2010 at 1:36

GoogleCodeExporter commented 8 years ago
I see.. obviously a misunderstanding on my site. Thanks for the explanation.

Original comment by h.niederhausen@googlemail.com on 31 Mar 2010 at 1:40

GoogleCodeExporter commented 8 years ago
Okay, np. I close this issue

Original comment by lars.he...@gmail.com on 31 Mar 2010 at 1:41