Module: RTM::IO::TOXTM2::Topic
- Defined in:
- lib/rtm/io/to_xtm2.rb
Instance Method Summary collapse
-
#to_xtm2 ⇒ Object
returns the XTM 2.0 representation of this topic as an REXML::Element.
-
#to_xtm2_ref ⇒ Object
returns the an (internal) XTM 2.0 reference to this topic.
-
#xtm2_id ⇒ Object
this is a helper-method for the to_xtm2 amd to_xtm2_ref methods.
Instance Method Details
#to_xtm2 ⇒ Object
returns the XTM 2.0 representation of this topic as an REXML::Element
65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/rtm/io/to_xtm2.rb', line 65 def to_xtm2 #topic = element topic { id, # (itemIdentity | subjectLocator | subjectIdentifier)*, # instanceOf?, (name | occurrence)* } x = REXML::Element.new('topic') x.add_attribute('id', xtm2_id ) item_identifiers.each { |ii| x << TOXTM2.locator(ii) } # itemIdentity subject_identifiers.each { |si| x << TOXTM2.locator(si, "subjectIdentifier") } # subjectIdentifier if item_identifiers.empty? && subject_identifiers.empty? TOXTM2.locator(xtm2_id) # itemIdentity end subject_locators.each { |sl| x << TOXTM2.locator(sl, "subjectLocator") } # subjectLocator # I guess we won't create instanceOf-Elements but instead type-instance associations. names.each { |n| x << n.to_xtm2 } occurrences.each { |o| x << o.to_xtm2 } x end |
#to_xtm2_ref ⇒ Object
returns the an (internal) XTM 2.0 reference to this topic
83 84 85 86 87 |
# File 'lib/rtm/io/to_xtm2.rb', line 83 def to_xtm2_ref x = REXML::Element.new 'topicRef' x.add_attribute('href', "##{xtm2_id}") x end |
#xtm2_id ⇒ Object
this is a helper-method for the to_xtm2 amd to_xtm2_ref methods
61 62 63 |
# File 'lib/rtm/io/to_xtm2.rb', line 61 def xtm2_id "t#{id}" end |