Open andrew2net opened 1 week ago
Agree @andrew2net .
For zeroAndMore
, oneAndMore
, we should just use cardinality such as min
, max
to set.
e.g.
class FullNameType < Lutaml::Model::Serializable
attribute :abbreviation, NameAbbreviation, optional: true
choice do
group do
attribute :prefix, Prefix, collection: [0, :inf]
attribute :forename, Forename, collection: [0, :inf]
attribute :formatted-initials, FormattedInitials, optional: true
attribute :surname, Surname
attribute :addition, Addition, collection: [0, :inf]
end
attribute :completeName, CompleteName
end
attribute :biblionote, BiblionNote, collection: [0, :inf]
attribute :variantname, VariantName, collection: [0, :inf]
...
end
@ronaldtse Yeah, this is just an idea. It requires working out a lot of details. For example, we may need to map our Relaton classes to data model attributes:
bibitem = mode.from_xml(File.read("bibitem.xml")) do
model :btitle, Relaton::Bib::Title
...
end
I'm trying to reimplement the Relaton data model with Shale. Shale is limited, especially in inheritance, multi-inheritance, recurrence, cloise, and repeated groups. I found some workarounds but the code becomes more complicated than if we don't use Shale. Also, it can parse and produce XML that is not valid against grammar. I started thinking that we could use the major Shale idea and spend our efforts on implementing a gem that reads RNG grammar files, creates Ruby objects for each defined element in the RNG files, and then parses and renders various serialization formats. So once the grammar is updated, the Relaton model will be updated immediately without any code changes. With the Shale, we will have pain after each data model update. I believe that we need to implement a Domain Specific Language (DSL) that allows us to describe data models in a way we do in the grammar. For example the definition in the grammar:
could be implemented using DSL:
Next, we can implement a model creator like:
and use the model to parse and serialize objects