Sha256: 9c138032648d8af7d11c7094c4f2ece7d6a58bfc2a99d591958d1caa9cc91f6f

Contents?: true

Size: 883 Bytes

Versions: 4

Compression:

Stored size: 883 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)
          unless options.empty?
            Deprecation.warn(self, "passing options to extract_xml is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")
          end
          result = TrajectPlus::Extraction.apply_extraction_options(result, options)
          accumulator.concat(result)
        end
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
traject_plus-1.3.0 lib/traject_plus/macros/xml.rb
traject_plus-1.2.2 lib/traject_plus/macros/xml.rb
traject_plus-1.1.1 lib/traject_plus/macros/xml.rb
traject_plus-1.1.0 lib/traject_plus/macros/xml.rb