The default Termium XML output looks like this:
<ns2:termium_extract xmlns:ns2="http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" language="EN"
xsi:schemaLocation="http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium http://termium.tpsgc-pwgsc.gc.ca/schemas/2012/06/Termium.xsd">
<extractLanguage language="EN" order="0" />
<extractLanguage language="FR" order="1" />
...
Here, the termium_extract element has a namespace marked as ns2, but its children have no namespaces.
Technically, it should be parsed like this:
module Termium
# For <extract>
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:
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.
The default Termium XML output looks like this:
Here, the
termium_extractelement has a namespace marked asns2, but its children have no namespaces.Technically, it should be parsed like this:
However, this fails because it treats all its children with the same
ns2namespace. Since the children elements have no namespace, they are all ignored.Instead, this would work:
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.