class CanonicalXTMWriter implements TopicMapWriterIF {

  @Override
  public void write(TopicMapIF topicmap) {
    DuplicateSuppressionUtils.removeDuplicates(topicmap);
    tmForFake = topicmap;
  
    base = topicmap.getStore().getBaseAddress().getAddress();
    strippedBase = stripLocator(base);

    Object[] topics = getTopics(topicmap);
    Object[] associations = getAssociations(topicmap);
    recordIndexes(topics, associations);
        
    out.startDocument();
    startElement(EL_TOPICMAP, reifier(topicmap));
    writeLocators(topicmap.getItemIdentifiers(), EL_ITEMIDENTIFIERS);
    
    for (int ix = 0; ix < topics.length; ix++)
      write((TopicIF) topics[ix]);

    for (int ix = 0; ix < associations.length; ix++)
      write((AssociationIF) associations[ix], ix + 1);

    endElement(EL_TOPICMAP);
    out.endDocument();
  }

  public  CanonicalXTMWriter(File file);
  public  CanonicalXTMWriter(OutputStream out);
  public  CanonicalXTMWriter(Writer out);

}