relaton / relaton-nist

NistBib: retrieve NIST Standards for bibliographic use using the BibliographicItem model
https://www.metanorma.com
MIT License
2 stars 1 forks source link

Do not use IsoBibliographicItem #7

Closed ronaldtse closed 5 years ago

ronaldtse commented 5 years ago
hit_collection = NistBib::NistBibliography.search("SP 800-37 Rev. 1")
item = hit_collection[0].fetch
item.to_xml
Traceback (most recent call last):
       14: from bin/console:14:in `<main>'
       13: from (irb):24
       12: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/iso_bibliographic_item.rb:262:in `to_xml'
       11: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/iso_bibliographic_item.rb:262:in `new'
       10: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/xml/builder.rb:293:in `initialize'
        9: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/iso_bibliographic_item.rb:263:in `block in to_xml'
        8: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/iso_bibliographic_item.rb:297:in `render_xml'
        7: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/xml/builder.rb:375:in `method_missing'
        6: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/xml/builder.rb:391:in `insert'
        5: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/iso_bibliographic_item.rb:314:in `block in render_xml'
        4: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/bibliographic_item.rb:70:in `to_xml'
        3: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/xml/builder.rb:375:in `method_missing'
        2: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/nokogiri-1.8.5/lib/nokogiri/xml/builder.rb:391:in `insert'
        1: from /Users/me/.rbenv/versions/2.5.1/lib/ruby/gems/2.5.0/gems/iso-bib-item-0.4.4/lib/iso_bib_item/bibliographic_item.rb:71:in `block in to_xml'

NoMethodError (undefined method `year' for nil:NilClass)

NistBib should not use IsoBibliographicItem (iso-bib-item). Instead, there should be a RelatonBibliographicItem (or just BibliographicItem) class that is inherited by NistBibliographicItem.

This issue should be considered together with https://github.com/metanorma/iso-bib-item/issues/8.

andrew2net commented 5 years ago

@ronaldtse suppose we should extract BibliographicItem class from iso-bib-item gem and create bib-item gem.

ronaldtse commented 5 years ago

@andrew2net can we extract it out to relaton-bib gem? Thanks!

andrew2net commented 5 years ago

@ronaldtse do you mean to create to new relaton-bib gem? Yes, sure.

ronaldtse commented 5 years ago

Yes. Thanks!

andrew2net commented 5 years ago

@ronaldtse I see the BibliographicItem class is outdated. There are differences between the class and grammar https://github.com/metanorma/relaton-models/blob/master/grammars/biblio.rnc Should we update the BibliographicItem class?

ronaldtse commented 5 years ago

Yes, probably.

@opoudjis , should @andrew2net update the BibliographicItem class according to your latest changes at https://github.com/metanorma/relaton-models/blob/master/grammars/biblio.rnc ? Thanks!

opoudjis commented 5 years ago

Wow. More refactoring.

Yes, although there shouldn't be any drastic changes there.

andrew2net commented 5 years ago

@ronaldtse, however, nist grammar https://github.com/metanorma/metanorma-model-iso/blob/master/grammars/nist.rnc inherit from isostandard, not from biblio. So NistBibliographicItem should inherit form IsoBibliographicItem.

# Currently we inherit from a namespaced grammar, isostandard. Until we inherit from isodoc,
# we cannot have a new default namespace: we will end up with a grammar with two different
# namespaces, one for isostandard and one for csand additions. And we do not want that.

include "isostandard.rnc" {
...
opoudjis commented 5 years ago

Well, that's a convenience in how I wrote the grammar. The upcoming task https://github.com/metanorma/relaton/issues/39 will differentiate a flavour-independent bibitem from a flavour-dependent bibdata; the flavour-independent bibitem should then migrate to biblio.rnc

opoudjis commented 5 years ago

So I'm assuming that relaton-bib will be propagated to all the other relaton gems eventually? I'm releasing it now to get nistbib to work, but nistbib is currently the only gem using it.

If relaton-bib is to be propagated to all the other relaton gems, the appropriate tickets will need to be created.

Welcome to refactoring Metanorma, Andrej >:-)

ronaldtse commented 5 years ago

@andrew2net ping on the answer:

So I'm assuming that relaton-bib will be propagated to all the other relaton gems eventually? I'm releasing it now to get nistbib to work, but nistbib is currently the only gem using it.

Is this all done? Thanks!

andrew2net commented 5 years ago

@ronaldtse I'm working on relaton-itu now. Hope to finish it today. So it will be done today.

ronaldtse commented 5 years ago

That's great, look forward to it! Thanks @andrew2net !