lib/bel/translator/plugins/xbel/evidence_handler.rb in bel-0.5.0 vs lib/bel/translator/plugins/xbel/evidence_handler.rb in bel-0.6.0

- old
+ new

@@ -191,23 +191,14 @@ @element_stack << :term end def start_parameter(attributes) if stack_top == :term - ns_id = attr_value(attributes, NS) - # XXX Hitting a SystemStackError on line 174 (inside call). - # Example: large_corpus.xbel - ns_sym = ns_id.to_sym - namespace_reference = @evidence.references.namespaces.find { |ns| - ns[:keyword] == ns_sym - } ns = - if namespace_reference - { - :prefix => namespace_reference[:keyword], - :url => namespace_reference[:uri] - } + if has_attr?(attributes, NS) + ns_id = attr_value(attributes, NS) + namespace_reference(ns_id, @evidence) else nil end @current_parameter = Parameter.new(ns, nil) end @@ -476,9 +467,29 @@ @element_stack.last end def attr_value(attributes, attr_name) attributes["bel:#{attr_name}"] + end + + def has_attr?(attributes, attr_name) + attributes.has_key?("bel:#{attr_name}") + end + + def namespace_reference(ns_id, evidence) + ns_id = ns_id.to_sym + namespace_reference = evidence.references.namespaces.find { |ns| + ns[:keyword] == ns_id + } + + if namespace_reference + { + :prefix => namespace_reference[:keyword], + :url => namespace_reference[:uri] + } + else + nil + end end end end end