Sha256: 505dc2e0fb7732eed1cac18e8478f3ab712d5400abf872cd5077b6b70d6e16b2

Contents?: true

Size: 1.68 KB

Versions: 6

Compression:

Stored size: 1.68 KB

Contents

# fgdc reader

# History:
#  Stan Smith 2018-05-04 add reader version to response object
#  Stan Smith 2017-08-10 original script

require 'nokogiri'
require_relative 'version'
require_relative 'modules/module_fgdc'

module ADIWG
   module Mdtranslator
      module Readers
         module Fgdc

            def self.readFile(file, hResponseObj)

               # add FGDC reader version
               hResponseObj[:readerVersionUsed] = ADIWG::Mdtranslator::Readers::Fgdc::VERSION

               # receive XML file
               if file.nil? || file == ''
                  hResponseObj[:readerStructureMessages] << 'XML file is missing'
                  hResponseObj[:readerStructurePass] = false
                  return {}
               end

               # file must be well formed XML
               begin
                  xDoc = Nokogiri::XML(file) { |form| form.strict }
               rescue Nokogiri::XML::SyntaxError => err
                  hResponseObj[:readerStructureMessages] << 'XML file is not well formed'
                  hResponseObj[:readerStructureMessages] << err
                  hResponseObj[:readerStructurePass] = false
                  return {}
               end

               # file must contain an fgdc <metadata> tag
               xMetadata = xDoc.xpath('/metadata')
               if xMetadata.empty?
                  hResponseObj[:readerValidationMessages] << 'FGDC file did not contain a <metadata> tag'
                  hResponseObj[:readerValidationPass] = false
                  return {}
               end

               # load fgdc file into internal object
               return Fgdc.unpack(xDoc, hResponseObj)

            end

         end
      end
   end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.14.1 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.14.0 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.13.3 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.13.2 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.13.1 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.13.0 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb