Sha256: 6cc4111fb1b22b601456560c3c27d2ad786a3cf2f951b151d13dc32024f9b294

Contents?: true

Size: 1.75 KB

Versions: 30

Compression:

Stored size: 1.75 KB

Contents

# fgdc reader

# History:
#  Josh Bradley 2018-11-1 format eror messages
#  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] << 'ERROR: 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] << 'ERROR: XML file is not well formed'
                  hResponseObj[:readerStructureMessages] << err.to_s
                  hResponseObj[:readerStructurePass] = false
                  return {}
               end

               # file must contain an fgdc <metadata> tag
               xMetadata = xDoc.xpath('/metadata')
               if xMetadata.empty?
                  hResponseObj[:readerValidationMessages] << 'ERROR: 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

30 entries across 30 versions & 1 rubygems

Version Path
adiwg-mdtranslator-2.19.0.pre.beta.31 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.30 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.29 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.28 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.27 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.26 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.13 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.12 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.11 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.10 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.9 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.8 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.19.0.pre.beta.7 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.4 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.2 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.1 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.0 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.0rc9 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.0rc8 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb
adiwg-mdtranslator-2.18.0rc7 lib/adiwg/mdtranslator/readers/fgdc/fgdc_reader.rb