Module: RTM::IO::TOXTM1::Topic

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 as an REXML::Element



63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
# File 'rtm/lib/rtm/io/to_xtm1.rb', line 63

def to_xtm1
  #topic = element topic { id,
  #                    (itemIdentity | subjectLocator | subjectIdentifier)*,
  #                    instanceOf?, (name | occurrence)* }
  x = REXML::Element.new('topic')
  x.add_attribute('id', xtm1_id )
  item_identifiers.each { |ii| x << TOXTM1.locator(ii) } # itemIdentity
  subject_identifiers.each { |si| x << TOXTM1.locator(si, "subjectIdentifier") } # subjectIdentifier
  if item_identifiers.empty? && subject_identifiers.empty?
    TOXTM1.locator(xtm1_id) # itemIdentity
  end
  subject_locators.each { |sl| x << TOXTM1.locator(sl, "subjectLocator") } # subjectLocator
  # I guess we won't create instanceOf-Elements but instead type-instance associations.
  names.each { |n| x << n.to_xtm1 }
  occurrences.each { |o| x << o.to_xtm1 }
  x
end

- (Object) to_xtm1_ref

returns the an (internal) XTM 2.0 reference to this topic



81
82
83
84
85
# File 'rtm/lib/rtm/io/to_xtm1.rb', line 81

def to_xtm1_ref
  x = REXML::Element.new 'topicRef'
  x.add_attribute('href', "##{xtm1_id}")
  x
end

- (Object) xtm1_id

this is a helper-method for the to_xtm1 amd to_xtm1_ref methods



59
60
61
# File 'rtm/lib/rtm/io/to_xtm1.rb', line 59

def xtm1_id
  "t#{id}"
end