Module: RTM::IO::FROMXTM2LX

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

Overview

XTM2 Export. Each Topic Maps Construct gets a to_xtm2 method. The result is a REXML::Element except for TopicMap where it is a REXML::Document.

Constant Summary

XTM2DEBUG =
false

Class Method Summary

Class Method Details

+ (Object) from_xtm2(source, base_locator, target = nil, options = {})

Reads XTM2 from source (io object). Example: RTM::IO::FROMXTM2.from_xtm2(File.open(file_name),“rtm.rubyforge.org/topicmaps/tm1/”) supported options: :strip_whitespace (defaults to false, may be set to true), :deprefix (defaults to nil, may be set to a string (or regex) which will be removed from the beginning of an (unresolved) item_identifier if it is there.



22
23
24
25
26
27
28
29
# File 'rtm/lib/rtm/io/from_xtm2_libxml.rb', line 22

def self.from_xtm2(source, base_locator, target=nil,options={})
  tm = RTM.create(base_locator) unless target
  parser = XML::SaxParser.new
  parser.callbacks = RTM::XML::LibXMLSax2wrapper.new(FROMXTM2::XTM2Listener.new(base_locator, target || tm, options))
  parser.filename = source
  parser.parse
  #true
end