Skip to content
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

XSD parser using LutaML-Model #2

Merged
merged 6 commits into from
Nov 20, 2024
Merged

Conversation

suleman-uzair
Copy link
Member

This PR adds XSD parsing support using LutaML-Model.

closes #1


map_attribute :name, to: :name
map_attribute :type, to: :type
map_element :annotation, to: :annotation, namespace: "http://www.w3.org/2001/XMLSchema", prefix: "xsd"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I find it strange that we need to repeat the namespace in every single element. Instead, we should respect the default namespace of the element, and only override it with a nil prefix if we want no namespace?

Copy link
Contributor

@ronaldtse ronaldtse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we add additional fixtures and test against round-tripping? One of the next steps is to handle the “imports”.

@ronaldtse
Copy link
Contributor

For additional XSD files, try the MathML one, the NIST Metaschema one and the OGC GML one.

@@ -13,3 +15,9 @@
c.syntax = :expect
end
end

def to_xml(parsed_schema, escape_content_tags: false)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@suleman-uzair can you see if the xml-c14n gem helps? We want to share code across all of these gems. Thanks.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you see if the xml-c14n gem helps?

@ronaldtse I have replaced equivalent-xml with xml-c14n gem, it works fine but the gsub! used in this method is still needed though.
The reason for using gsub is that when using map_all to process documentation tags in the schema that contain elements (tags), it is treated as text, which converts < and > to &lt; and &gt;, respectively, causing a failure in the matcher.

@ronaldtse
Copy link
Contributor

@suleman-uzair could you please help resolve the conflict with the gemspec file and we can merge this? Thanks!

module_function

def parse(xsd)
Lutaml::Model::Config.xml_adapter_type = :nokogiri
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We do not need to set the adapter inside every method call this can be done outside the method.

@suleman-uzair suleman-uzair marked this pull request as ready for review November 20, 2024 13:45
@suleman-uzair suleman-uzair merged commit 45c3a93 into main Nov 20, 2024
13 of 14 checks passed
@suleman-uzair suleman-uzair deleted the feature/parsing_XML_schema branch November 20, 2024 13:46
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Create LutaML XSD
3 participants