logicgraph_parser.rb revision 08464a6b0d787688a7a3d60e22c7dc9a62e30b71
0N/A# This module parses the logic graph outputed by Hets. 0N/A# It is a use-once-and-discard code and for this reason it does not have 0N/A# Author:: Daniel Couto Vale (mailto:danielvale@uni-bremen.de) 0N/A# Copyright:: Copyright (c) 2013 Bremen University, SFBTR8 0N/A# License:: Distributed as a part of Ontohub. 0N/A # Parses the given string and executes the callback for each symbol 0N/A # Create a new parser 0N/A # Feed the parser some XML 0N/A # Listener for the SAX Parser 0N/A # the callback function is called for each Symbol tag 0N/A # Makes a logic mapping singleton for a given key # Make a logic singleton for a given key # Make a language singleton for a given key # Parses the element opening tag callback(:root, Hash[*[attributes]]) hash = Hash[*[attributes]] @current_logic = make_logic(hash['name']) @current_language = make_language(hash['name']) @current_support = make_support(hash['name'], hash['name']) callback(:logic, @current_logic) callback(:language, @current_language) callback(:support, @current_support) hash = Hash[*[attributes]] @current_comorphism = make_mapping(hash['name']) if @path[-2] == SOURCE_SUBLOGIC # @current_comorphism.source = @current_source_sublogic elsif @path[-2] == TARGET_SUBLOGIC # @current_comorphism.target = @current_target_sublogic if hash['is_weakly_amalgamable'] == 'TRUE' @current_comorphism.exactness = LogicMapping::EXACTNESSES[2] @current_comorphism.exactness = LogicMapping::EXACTNESSES[0] if hash['has_model_expansion'] == 'TRUE' @current_comorphism.faithfulness = LogicMapping::FAITHFULNESSES[2] @current_comorphism.faithfulness = LogicMapping::FAITHFULNESSES[0] @current_comorphism.source = make_logic(hash['source']) @current_comorphism.target = make_logic(hash['target']) if !@current_comorphism.source.nil? && !@current_comorphism.target.nil? callback(:logic_mapping, @current_comorphism) hash = Hash[*[attributes]] @current_source_sublogic = make_logic(hash['name']) callback(:logic, @current_source_sublogic) hash = Hash[*[attributes]] @current_target_sublogic = make_logic(hash['name']) callback(:logic, @current_target_sublogic) hash = Hash[*[attributes]] serialization = @current_language.serializations.create serialization.name = name serialization.extension = name serialization.mimetype = name @current_language.serializations << serialization # Parses the element closing tag callback(:logic, @current_logic) callback(:language, @current_language) callback(:support, @current_support) if @path[-1] == SOURCE_SUBLOGIC elsif @path[-1] == TARGET_SUBLOGIC callback(:logic_mapping, @current_comorphism) @current_comorphism = nil @current_logic.description = text if @current_logic @current_language.description = text if @current_language @callbacks[name].try :call, args