Module: RTM::AR::IO::TOXTM1

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

Overview

XTM1 Export

Defined Under Namespace

Modules: Association, AssociationRole, Occurrence, Topic, TopicMap, TopicName, Variant

Class Method Summary collapse

Class Method Details

.locator(loc, tagname = "itemIdentity") ⇒ Object



31
32
33
34
35
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 31

def self.locator(loc, tagname = "itemIdentity")
  x = REXML::Element.new(tagname)
  x.add_attribute('href',loc.to_s) # loc could be Locator or String, to_s serves both

  x
end

.scope(scope) ⇒ Object



8
9
10
11
12
13
14
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 8

def self.scope(scope)
  res = REXML::Element.new('scope')
  scope.each do |s|
    res << s.to_xtm_ref
  end
  res
end

.type(type) ⇒ Object



15
16
17
18
19
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 15

def self.type(type)
  res = REXML::Element.new('type')
  res << type.to_xtm_ref
  res
end

.value(datatype, value) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
# File 'lib/rtm/activerecord/io/to_xtm1.rb', line 20

def self.value(datatype, value)
  if datatype == RTM::PSI[:IRI]
    res = REXML::Element.new 'resourceRef'
    res.add_attribute('href', value)
  else
    res = REXML::Element.new 'resourceData'
    res.add_attribute('datatype', datatype) if datatype
    res.text = value
  end
  res
end