lib/adiwg/mdtranslator/writers/iso/classes/class_taxonClassification.rb in adiwg-mdtranslator-0.10.2 vs lib/adiwg/mdtranslator/writers/iso/classes/class_taxonClassification.rb in adiwg-mdtranslator-0.12.0
- old
+ new
@@ -1,65 +1,76 @@
# ISO <<Class>> MD_TaxonCl
# writer output in XML
# History:
# Stan Smith 2013-11-19 original script
+# Stan Smith 2014-12-12 refactored to handle namespacing readers and writers
-class MD_TaxonCl
+module ADIWG
+ module Mdtranslator
+ module Writers
+ module Iso
- def initialize(xml)
- @xml = xml
- end
+ class MD_TaxonCl
- def writeXML(aTaxonCl)
+ def initialize(xml)
+ @xml = xml
+ end
- # take first element in array
- hTaxonCl = aTaxonCl[0]
+ def writeXML(aTaxonCl)
- @xml.tag!('gmd:MD_TaxonCl') do
+ # take first element in array
+ hTaxonCl = aTaxonCl[0]
- # taxon classification - common name
- s = hTaxonCl[:commonName]
- if !s.nil?
- @xml.tag!('gmd:common') do
- @xml.tag!('gco:CharacterString',s)
- end
- elsif $showAllTags
- @xml.tag!('gmd:common')
- end
+ @xml.tag!('gmd:MD_TaxonCl') do
- # taxon classification - taxon rank name - required
- s = hTaxonCl[:taxRankName]
- if s.nil?
- @xml.tag!('gmd:taxonrn',{'gco:nilReason'=>'missing'})
- else
- @xml.tag!('gmd:taxonrn') do
- @xml.tag!('gco:CharacterString',s)
- end
+ # taxon classification - common name
+ s = hTaxonCl[:commonName]
+ if !s.nil?
+ @xml.tag!('gmd:common') do
+ @xml.tag!('gco:CharacterString', s)
+ end
+ elsif $showAllTags
+ @xml.tag!('gmd:common')
+ end
- end
+ # taxon classification - taxon rank name - required
+ s = hTaxonCl[:taxRankName]
+ if s.nil?
+ @xml.tag!('gmd:taxonrn', {'gco:nilReason' => 'missing'})
+ else
+ @xml.tag!('gmd:taxonrn') do
+ @xml.tag!('gco:CharacterString', s)
+ end
- # taxon classification - taxon rank value - required
- s = hTaxonCl[:taxRankValue]
- if s.nil?
- @xml.tag!('gmd:taxonrv',{'gco:nilReason'=>'missing'})
- else
- @xml.tag!('gmd:taxonrv') do
- @xml.tag!('gco:CharacterString',s)
- end
+ end
- end
+ # taxon classification - taxon rank value - required
+ s = hTaxonCl[:taxRankValue]
+ if s.nil?
+ @xml.tag!('gmd:taxonrv', {'gco:nilReason' => 'missing'})
+ else
+ @xml.tag!('gmd:taxonrv') do
+ @xml.tag!('gco:CharacterString', s)
+ end
- # taxon classification - classification - recursive
- aTaxonCl.slice!(0)
- unless aTaxonCl.empty?
- @xml.tag!('gmd:taxonCl') do
- writeXML(aTaxonCl)
- end
- end
+ end
- end
+ # taxon classification - classification - recursive
+ aTaxonCl.slice!(0)
+ unless aTaxonCl.empty?
+ @xml.tag!('gmd:taxonCl') do
+ writeXML(aTaxonCl)
+ end
+ end
+ end
- end
+ end
+
+ end
+
+ end
+ end
+ end
end