-
Notifications
You must be signed in to change notification settings - Fork 2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Replace xpath #22
Replace xpath #22
Conversation
As parsing xmi file by Some of the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very happy with the changes so far!
lib/lutaml/xmi/parsers/xml.rb
Outdated
# @param options [Hash] options for parsing | ||
# @return [Lutaml::Uml::Document] | ||
def self.parse(xml, _options = {}) | ||
xml_content = File.read(xml).gsub("\t", " ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t need to remove Tabs because we are not doing a compare.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed in 3fc1ece.
lib/lutaml/xmi/parsers/xml.rb
Outdated
# @xmi:type="uml:AssociationClass"] | ||
def serialize_model_classes(package, model) | ||
package.packaged_element.select { |e| | ||
e.type == "uml:Class" || e.type == "uml:AssociationClass" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we do “is_a?(Uml::Class)” something like that?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will implement is_type?
in Shale::Mapper
class to handle these issues.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don’t want new methods? Aren’t AssociatedClass etc separate classes?
lib/lutaml/xmi/parsers/xml.rb
Outdated
# @note xpath ./packagedElement[@xmi:type="uml:Enumeration"] | ||
def serialize_model_enums(package) | ||
package.packaged_element | ||
.select { |e| e.type == "uml:Enumeration" }.map do |enum| |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same here, can we use “is_a?”?
lib/lutaml/xmi/parsers/xml.rb
Outdated
# @note xpath | ||
# %(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"]) | ||
def fetch_owned_attribute_node(xmi_id) | ||
node = main_model.xpath(%(//ownedAttribute[@association]/type[@xmi:idref="#{xmi_id}"])).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will we replace this later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be replaced later.
lib/lutaml/xmi/parsers/xml.rb
Outdated
definition: lookup_attribute_definition(attribute), | ||
} | ||
end | ||
klass.owned_attribute.select { |attr| attr.type == "uml:Property" } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we use “is_a?”?
lib/lutaml/xmi/parsers/xml.rb
Outdated
doc_node = main_model.xpath(%(//element[@xmi:idref="#{xmi_id}"]/properties)).first | ||
return unless doc_node | ||
|
||
doc_node.attributes[attr_name]&.value | ||
end | ||
|
||
def lookup_attribute_definition(node) | ||
xmi_id = node["xmi:id"] | ||
def lookup_attribute_documentation(xmi_id) | ||
doc_node = main_model.xpath(%(//attribute[@xmi:idref="#{xmi_id}"]/documentation)).first |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We’ll replace this later?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it should be replaced later.
No description provided.