Sha256: 71764ad9fed6ac1184065c8ad6b71fe8f4b159c7f7879d2c4cbf430c1b461907

Contents?: true

Size: 672 Bytes

Versions: 5

Compression:

Stored size: 672 Bytes

Contents

# frozen_string_literal: true

module TrajectPlus
  module Macros
    # Macros for extracting MODS values from Nokogiri documents
    module Xml
      # @param xpath [String] the xpath query expression
      # @param namespaces [Hash<String,String>] The namespaces for the xpath query
      # @param options [Hash] other options, may include :trim
      def extract_xml(xpath, namespaces, options = {})
        lambda do |xml, accumulator, _context|
          result = xml.xpath(xpath, namespaces).map(&:text)
          result = TrajectPlus::Extraction.apply_extraction_options(result, options)
          accumulator.concat(result)
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
traject_plus-1.0.0 lib/traject_plus/macros/xml.rb
traject_plus-0.1.0 lib/traject_plus/macros/xml.rb
traject_plus-0.0.3 lib/traject_plus/macros/xml.rb
traject_plus-0.0.2 lib/traject_plus/macros/xml.rb
traject_plus-0.0.1 lib/traject_plus/macros/xml.rb