-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* XSD parsing LutaML-Model classes * chore: removed zeitwerk default logger * Added round-trip xml specs, classes, and attributes * fix: failing specs * chore: updated dir path string * chore: changed matcher gem and moved adapter from method to base file --------- Co-authored-by: suleman-uzair <[email protected]>
- Loading branch information
1 parent
e135689
commit 45c3a93
Showing
44 changed files
with
4,096 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,10 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
require_relative "xsd/version" | ||
require "zeitwerk" | ||
require "lutaml/model" | ||
require_relative "xsd/xsd" | ||
|
||
module Lutaml | ||
module Xsd | ||
class Error < StandardError; end | ||
# Your code goes here... | ||
end | ||
end | ||
Lutaml::Model::Config.xml_adapter_type = :nokogiri | ||
|
||
loader = Zeitwerk::Loader.for_gem(warn_on_extra_files: true) | ||
loader.push_dir("#{__dir__}/xsd", namespace: Lutaml::Xsd) | ||
loader.ignore("#{__dir__}/lib/lutaml/xsd.rb") | ||
loader.setup |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Annotation < Lutaml::Model::Serializable | ||
attribute :documentation, Documentation, collection: true | ||
|
||
xml do | ||
root "annotation", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_element :documentation, to: :documentation | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Any < Lutaml::Model::Serializable | ||
attribute :namespace, :string | ||
attribute :process_contents, :string | ||
|
||
xml do | ||
root "any", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :namespace, to: :namespace | ||
map_attribute :processContents, to: :process_contents | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Attribute < Lutaml::Model::Serializable | ||
attribute :use, :string | ||
attribute :name, :string | ||
attribute :type, :string | ||
attribute :default, :string | ||
attribute :annotation, Annotation, collection: true | ||
attribute :simple_type, SimpleType, collection: true | ||
|
||
xml do | ||
root "attribute", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :use, to: :use | ||
map_attribute :name, to: :name | ||
map_attribute :type, to: :type | ||
map_attribute :default, to: :default | ||
map_element :annotation, to: :annotation | ||
map_element :simpleType, to: :simple_type | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class AttributeGroup < Lutaml::Model::Serializable | ||
attribute :name, :string | ||
attribute :ref, :string | ||
attribute :annotation, Annotation, collection: true | ||
attribute :attribute, Attribute, collection: true | ||
|
||
xml do | ||
root "attributeGroup", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :ref, to: :ref | ||
map_attribute :name, to: :name | ||
map_element :annotation, to: :annotation | ||
map_element :attribute, to: :attribute | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Sequence < Lutaml::Model::Serializable; end | ||
|
||
class Choice < Lutaml::Model::Serializable | ||
attribute :any, Any, collection: true | ||
attribute :min_occurs, :string | ||
attribute :max_occurs, :string | ||
attribute :element, Element, collection: true | ||
attribute :sequence, Sequence, collection: true | ||
attribute :group, Group, collection: true | ||
|
||
xml do | ||
root "choice", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :minOccurs, to: :min_occurs | ||
map_attribute :maxOccurs, to: :max_occurs | ||
map_element :element, to: :element | ||
map_element :sequence, to: :sequence | ||
map_element :group, to: :group | ||
map_element :any, to: :any | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class ComplexContent < Lutaml::Model::Serializable | ||
attribute :extension, Extension, collection: true | ||
|
||
xml do | ||
root "complexContent", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_element :extension, to: :extension | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class ComplexType < Lutaml::Model::Serializable | ||
attribute :name, :string | ||
attribute :mixed, :string | ||
attribute :abstract, :string | ||
attribute :choice, Choice, collection: true | ||
attribute :sequence, Sequence, collection: true | ||
attribute :attribute, Attribute, collection: true | ||
attribute :annotation, Annotation, collection: true | ||
attribute :attribute_group, AttributeGroup, collection: true | ||
attribute :simple_content, SimpleContent, collection: true | ||
attribute :complex_content, ComplexContent, collection: true | ||
|
||
xml do | ||
root "complexType", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :name, to: :name | ||
map_attribute :mixed, to: :mixed | ||
map_attribute :abstract, to: :abstract | ||
map_element :choice, to: :choice | ||
map_element :sequence, to: :sequence | ||
map_element :attribute, to: :attribute | ||
map_element :annotation, to: :annotation | ||
map_element :attributeGroup, to: :attribute_group | ||
map_element :simpleContent, to: :simple_content | ||
map_element :complexContent, to: :complex_content | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Documentation < Lutaml::Model::Serializable | ||
attribute :content, :string | ||
|
||
xml do | ||
root "documentation" | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_all to: :content | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Element < Lutaml::Model::Serializable | ||
attribute :name, :string | ||
attribute :type, :string | ||
attribute :default, :string | ||
attribute :min_occurs, :string | ||
attribute :max_occurs, :string | ||
attribute :key, Key, collection: true | ||
attribute :unique, Unique, collection: true | ||
attribute :complex_type, ComplexType, collection: true | ||
attribute :simple_type, SimpleType, collection: true | ||
attribute :annotation, Annotation, collection: true | ||
|
||
xml do | ||
root "element", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :name, to: :name | ||
map_attribute :type, to: :type | ||
map_attribute :default, to: :default | ||
map_attribute :minOccurs, to: :min_occurs | ||
map_attribute :maxOccurs, to: :max_occurs | ||
map_element :complexType, to: :complex_type | ||
map_element :simpleType, to: :simple_type | ||
map_element :annotation, to: :annotation | ||
map_element :unique, to: :unique | ||
map_element :key, to: :key | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Enumeration < Lutaml::Model::Serializable | ||
attribute :value, :string | ||
attribute :annotation, Annotation, collection: true | ||
|
||
xml do | ||
root "enumeration", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :value, to: :value | ||
map_element :annotation, to: :annotation | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Extension < Lutaml::Model::Serializable | ||
attribute :base, :string | ||
attribute :sequence, Sequence, collection: true | ||
attribute :attribute, Attribute, collection: true | ||
attribute :annotation, Annotation, collection: true | ||
attribute :attribute_group, AttributeGroup, collection: true | ||
|
||
xml do | ||
root "extension", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :base, to: :base | ||
map_element :sequence, to: :sequence | ||
map_element :attribute, to: :attribute | ||
map_element :annotation, to: :annotation | ||
map_element :attributeGroup, to: :attribute_group | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Field < Lutaml::Model::Serializable | ||
attribute :xpath, :string | ||
|
||
xml do | ||
root "field", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :xpath, to: :xpath | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Sequence < Lutaml::Model::Serializable; end | ||
class Choice < Lutaml::Model::Serializable; end | ||
|
||
class Group < Lutaml::Model::Serializable | ||
attribute :ref, :string | ||
attribute :name, :string | ||
attribute :min_occurs, :string | ||
attribute :max_occurs, :string | ||
attribute :choice, Choice, collection: true | ||
attribute :sequence, Sequence, collection: true | ||
attribute :annotation, Annotation, collection: true | ||
|
||
xml do | ||
root "group", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :ref, to: :ref | ||
map_attribute :name, to: :name | ||
map_attribute :minOccurs, to: :min_occurs | ||
map_attribute :maxOccurs, to: :max_occurs | ||
map_element :annotation, to: :annotation | ||
map_element :sequence, to: :sequence | ||
map_element :choice, to: :choice | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Import < Lutaml::Model::Serializable | ||
attribute :id, :string | ||
attribute :namespace, :string | ||
|
||
xml do | ||
root "import", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_attribute :id, to: :id | ||
map_attribute :namespace, to: :namespace | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
# frozen_string_literal: true | ||
|
||
module Lutaml | ||
module Xsd | ||
class Include < Lutaml::Model::Serializable | ||
attribute :annotation, Annotation, collection: true | ||
|
||
xml do | ||
root "include", mixed: true | ||
namespace "http://www.w3.org/2001/XMLSchema", "xsd" | ||
|
||
map_element :annotation, to: :annotation | ||
end | ||
end | ||
end | ||
end |
Oops, something went wrong.