Open ronaldtse opened 3 weeks ago
We may need to use the raw: true
option for the Entry
element because we don't know what's going to go in there.
These are enhancements we need in lutaml-model:
Ping @HassanAkbar @suleman-uzair for thoughts.
So I fixed the "native round-trip spec" but there is a problem with <entry>
.
In the XML file, it contains this content (the spec passes if I comment that line out):
<row>
<entry>b1</entry>
<entry>b2</entry>
<entry>b3</entry>
<entry>b4</entry>
<entry morerows='1' valign='middle'><para> <!-- Pernicous Mixed Content -->
Vertical Span</para></entry>
</row>
The element <entry ...><para>...</para></entry>
fails because the <para>...</para>
content is not defined in lutaml-model, and therefore omitted from the re-generated content.
This is a case where the content of an element is not defined, and we need to implement some pass-through.
Clearly, map_all
won't work here because we still need to retain the attributes.
So I thought of using raw: true
:
module Oasis
module Etm
class Entry < Lutaml::Model::Serializable
attribute :colname, :string
attribute :content, :string, raw: true
# ...
xml do
root "entry"
# Attribute mappings
map_attribute "colname", to: :colname
# ...
# Content mapping
map_content to: :content
end
end
end
end
But it still doesn't work.
We need to handle this case gracefully because it is a clear requirement.
The above problem depends on this fix:
Ping @HassanAkbar @suleman-uzair for comments.
@ronaldtse There're only two specs keep failing now, but shouldn't they be put in niso-jats
or docbook
gem?
So different XML schemas use the same OASIS table XML, but use different namespaces. The tests from "isosts" are also from "isosts", which is an older XML schema that adopted the OASIS table XML.
I suspect that we should allow an easy way to accept different namespaces?
@ronaldtse Yeah, we need to change lutaml-model
@ronaldtse @HassanAkbar It's like we may need something like
in lutaml-model
@Novtopro Good idea. This might work, I'll try working on this and see if it affects other specs or not.
Actually, I think we are doing it for the first level, not sure about passing it down to other elements. I'll check this and get back to you.
Failures:
The round-tripping specs are failing for a few reasons:
xmlns:oasis="-//OASIS//DTD XML Exchange Table Model 19990315//EN"
. By default the Table class does not use any namespace. We need to update the specs (with a wrapping class) to work with this additional namespace.xmlns:oasis="http://docs.oasis-open.org/ns/oasis-exchange/table"
. We need to update the specs (new wrapping class) to parse this.native/
file is failing as element order is necessary in the table. For text cells, we need to applymixed: true
. For elements with order sensitive children, apply theorder: true
option.