Module: RTM::IO::TOXTM1::TopicMap

Defined in:
rtm/lib/rtm/io/to_xtm1.rb

Instance Method Summary

Instance Method Details

- (Object) to_xtm1

returns the XTM 2.0 representation of this topic map as an REXML::Document, ready for outputting



39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
# File 'rtm/lib/rtm/io/to_xtm1.rb', line 39

def to_xtm1
  # topicMap = element topicMap { reifiable, version, mergeMap*,
  #                               (topic | association)* }
  doc = REXML::Document.new
  doc << REXML::XMLDecl.new
  x = doc.add_element 'topicMap', {'xmlns' => 'http://www.topicmaps.org/xtm/', 'version' => '2.0'}
  x.add_attribute('reifier', reifier.xtm1_id) if reifier
  x << REXML::Comment.new("Topics count: #{topics.size}")
  x << REXML::Comment.new("Associations count: #{associations.size}")
  item_identifiers.each { |ii| x << TOXTM1.locator(ii) } # itemIdentity
  # mergeMap not used
  topics.each { |t| x << t.to_xtm1 }
  associations.each { |a| x << a.to_xtm1 }
  doc
  x
end