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

to_xml Method Behavior is Inconsistent #204

Open
0arm0 opened this issue Dec 10, 2024 · 3 comments
Open

to_xml Method Behavior is Inconsistent #204

0arm0 opened this issue Dec 10, 2024 · 3 comments

Comments

@0arm0
Copy link

0arm0 commented Dec 10, 2024

image

The to_xml method in the Atmospheric::Export::Iso25331975::GroupBase class exhibits inconsistent behavior. The following scenarios were tested:

Calling the Class Method to_xml with an Object:

obj = Atmospheric::Export::Iso25331975::GroupBase.new
Atmospheric::Export::Iso25331975::GroupBase.to_xml(obj)
Result: Returns "<test/>".

Calling the Instance Method to_xml:

Atmospheric::Export::Iso25331975::GroupBase.new.to_xml
Result: Returns nil.

This behavior is unexpected because the instance method to_xml should ideally provide serialized XML output for the object's data. However, it returns nil, while the class method returns an arbitrary XML string ("").

Steps to Reproduce:

Create an instance of GroupBase:

obj = Atmospheric::Export::Iso25331975::GroupBase.new

Test the class method to_xml:

Atmospheric::Export::Iso25331975::GroupBase.to_xml(obj)
Test the instance method to_xml:

Atmospheric::Export::Iso25331975::GroupBase.new.to_xml
Expected Behavior:

The to_xml method (either class or instance) should return consistent XML serialization for the object's data.
If the to_xml method is not fully implemented, it should raise an appropriate error or return a meaningful placeholder, not nil.
Actual Behavior:

The instance method to_xml returns nil.
The class method to_xml returns a static placeholder XML ("").

@ronaldtse
Copy link
Contributor

@0arm0 can you provide more information on how Atmospheric::Export::Iso25331975::GroupBase is defined? Is it inherited from Lutaml::Model::Serializable? Does it have attributes defined?

As you know Lutaml::Model::Serializable provides serialization methods on instances, not classes.

I don't know on top of my head whether is a valid use case to apply serialization methods to classes directly. (Probably?)

@0arm0
Copy link
Author

0arm0 commented Dec 10, 2024

@0arm0 can you provide more information on how Atmospheric::Export::Iso25331975::GroupBase is defined? Is it inherited from Lutaml::Model::Serializable? Does it have attributes defined?

As you know Lutaml::Model::Serializable provides serialization methods on instances, not classes.

I don't know on top of my head whether is a valid use case to apply serialization methods to classes directly. (Probably?)

@ronaldtse here is how I am using Lutaml::Model::Serializable in my class.
This could be just a workaround to apply serialization methods to classes directly incase the instance method doesnt work. Just like my case.

image

@ronaldtse
Copy link
Contributor

@0arm0 I would suggest not using hash as an attribute type but directly applying attributes to the values, and inner Lutaml::Model::Serializable classes as intermediary objects.

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

No branches or pull requests

2 participants