Closed andrew2net closed 2 months ago
@andrew2net whats the reason we use different names?
One way to do it is to inherit one class from another class and they share the same content but just a different root?
The reason is that they do different things in Metanorma: metadata of a document vs bibliographical item within a document.
@ronaldtse The problem is when Shale parses bibitem
it creates an object of Bibitem, and the object can render only bibitem
, it can't render anything else.
I think we can use BibliographicItem as a custom model, so when we parse bibitem or bibdata we can get the custom model from them, and to render output we should create Bibitem or Bibdate mapper using BibliographicItem's attributes.
I'll try this approach, and close this issue if it works.
@andrew2net how did you resolve this issue?
Did this approach work for you?
class BibData
attribute '...'
xml do
root 'bibdata'
map_attribute '...'
end
end
class BibItem < BibData
xml do
root 'bibitem'
map_attribute '...'
end
end
@ronaldtse I found out that if a custom model is used, it's possible to render an item with Bibitem.to_xml(item)
or Bibdata.to_xml(item)
, whatever we need.
Relaton has two slightly different XML representations of BibliongraphicItem. These representations have different root elements:
bibitem
andbibdata
. We can make mappings for each XML representation but I don't see how to create BibliographicItem frombibitem
and then renderbibdata
output, or vice versa. Our BibliograpnicItem can output both XML variants, but with Shale we can only create Bibitem class frombibitem
element and Bibdata class frombibdata
element. Any ideas?