Module: RDF::RDFXML::Reader::Nokogiri

Defined in:
vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/nokogiri.rb

Overview

Nokogiri implementation of an XML parser.

Defined Under Namespace

Classes: NodeProxy, NodeSetProxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.librarySymbol

Returns the name of the underlying XML library.

Returns:



12
13
14
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/nokogiri.rb', line 12

def self.library
  :nokogiri
end

Instance Method Details

#doc_errorsObject

Document errors



283
284
285
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/nokogiri.rb', line 283

def doc_errors
  @doc.errors
end

#initialize_xml(input, **options)

This method returns an undefined value.

Initializes the underlying XML library.

Parameters:



254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/nokogiri.rb', line 254

def initialize_xml(input, **options)
  require 'nokogiri' unless defined?(::Nokogiri)
  @doc = case input
  when ::Nokogiri::XML::Document
    input
  else
    # Try to detect charset from input
    options[:encoding] ||= input.charset if input.respond_to?(:charset)
    
    # Otherwise, default is utf-8
    options[:encoding] ||= 'utf-8'
    options[:encoding] = options[:encoding].to_s if options[:encoding]

    ::Nokogiri::XML.parse(input.respond_to?(:read) ? input.read : input.to_s, base_uri.to_s, options[:encoding]) do |config|
      config.noent
    end
  end
end

#rootObject

Return proxy for document root



277
278
279
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/nokogiri.rb', line 277

def root
  @root ||= NodeProxy.new(@doc.root) if @doc && @doc.root
end