def start_tag(prefix, tag, namespaces, attributes)
eRef = nil
if @elementstack.last
eRef = eAllReferences(@elementstack.last).find{|r|r.name == tag}
if eRef
if attributes["xsi:type"] && attributes["xsi:type"] =~ /ecore:(\w+)/
class_name = $1
attributes.delete("xsi:type")
else
class_name = eRef.eType.name
end
else
raise "Reference not found: #{tag} on #{@elementstack.last}"
end
else
class_name = tag
end
eClass = RGen::ECore.ecore.eClassifiers.find{|c| c.name == class_name}
if eClass
obj = RGen::ECore.const_get(class_name).new
if attributes["xmi:id"]
@element_by_id[attributes["xmi:id"]] = obj
attributes.delete("xmi:id")
end
if eRef
if eRef.many
@elementstack.last.addGeneric(eRef.name, obj)
else
@elementstack.last.setGeneric(eRef.name, obj)
end
end
@env << obj
@elementstack.push obj
else
log WARN, "Class not found: #{class_name}"
@elementstack.push nil
end
attributes.each_pair do |attr, value|
set_attribute_internal(attr, value)
end
end