glossarist / glossarist/termium
lutaml-model broken support of namespace-less child elements under a namespaced parent
- Dominant language
- Ruby
- Stars
- 1
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
The default Termium XML output looks like this:
```xml
...
```
Here, the `termium_extract` element has a namespace marked as `ns2`, but its children have no namespaces.
Technically, it should be parsed like this:
```ruby
module Termium
# For
class Extract < Lutaml::Model::Serializable
attribute :language, :string
attribute :extract_language, ExtractLanguage, collection: true
attribute :core, Core, collection: true
xml do
root "termium_extract"
namespace "http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium", "ns2"
map_attribute "language", to: :language, namespace: nil
map_element "extractLanguage", to: :extract_language, namespace: nil
map_element "core", to: :core, namespace: nil
end
end
end
```
However, this fails because it treats all its children with the same `ns2` namespace. Since the children elements have no namespace, they are all ignored.
Instead, this would work:
```ruby
module Termium
class Extract < Lutaml::Model::Serializable
attribute :language, :string
attribute :extract_language, ExtractLanguage, collection: true
attribute :core, Core, collection: true
xml do
root "termium_extract"
map_attribute "language", to: :language
map_element "extractLanguage", to: :extract_language
map_element "core", to: :core
end
end
end
```
Which is treating the element itself with no namespace, and the children have no namespace. This generates proper XML.
This is a bug in lutaml-model.
This can be found reproducible in the PR.
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.