Sha256: 5e156bdb7ca6484bbde9c68cadb532ed6e78dc2d0329d11daab35f4bca20ef07

Contents?: true

Size: 1 KB

Versions: 4

Compression:

Stored size: 1 KB

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 = {})
        Deprecation.warn(self, "extract_xml is deprecated and will be removed in the next major release. Use the Traject 3 pipeline instead")

        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-2.0.1 lib/traject_plus/macros/xml.rb
traject_plus-2.0.0 lib/traject_plus/macros/xml.rb
traject_plus-1.2.1 lib/traject_plus/macros/xml.rb
traject_plus-1.2.0 lib/traject_plus/macros/xml.rb