Sha256: 3c4e6ba5dd3192325c49a792d950591dae7ff357a4c4cf5bdabd4b0f810e585f

Contents?: true

Size: 1.26 KB

Versions: 11

Compression:

Stored size: 1.26 KB

Contents

# frozen_string_literal: true

module Nokogiri
  module XML
    class XPathContext
      ###
      # Register namespaces in +namespaces+
      def register_namespaces(namespaces)
        namespaces.each do |key, value|
          key = key.to_s.gsub(/.*:/, "") # strip off 'xmlns:' or 'xml:'

          register_ns(key, value)
        end
      end

      def register_variables(binds)
        return if binds.nil?

        binds.each do |key, value|
          key = key.to_s

          register_variable(key, value)
        end
      end

      if Nokogiri.uses_libxml?
        def reset
          return unless

          @registered_namespaces.each do |key, _|
            register_ns(key, nil)
          end
          unless @registered_namespaces.empty?
            warn "Nokogiri::XML::XPathContext#reset: unexpected registered namespaces: #{@registered_namespaces.keys}"
            @registered_namespaces.clear
          end

          @registered_variables.each do |key, _|
            register_variable(key, nil)
          end
          unless @registered_variables.empty?
            warn "Nokogiri::XML::XPathContext#reset: unexpected registered variables: #{@registered_variables.keys}"
            @registered_variables.clear
          end
        end
      end
    end
  end
end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
nokogiri-1.18.0.rc1-x86_64-linux-musl lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-x86_64-linux-gnu lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-x86_64-darwin lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-x64-mingw-ucrt lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-java lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1 lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-arm-linux-musl lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-arm-linux-gnu lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-arm64-darwin lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-aarch64-linux-musl lib/nokogiri/xml/xpath_context.rb
nokogiri-1.18.0.rc1-aarch64-linux-gnu lib/nokogiri/xml/xpath_context.rb