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

Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/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.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/lib/rdf/rdfxml/reader/nokogiri.rb', line 12

def self.library
  :nokogiri
end

Instance Method Details

#doc_errorsObject

Document errors



259
260
261
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/lib/rdf/rdfxml/reader/nokogiri.rb', line 259

def doc_errors
  @doc.errors
end

#initialize_xml(input, **options)

This method returns an undefined value.

Initializes the underlying XML library.

Parameters:



230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/lib/rdf/rdfxml/reader/nokogiri.rb', line 230

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



253
254
255
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-rdfxml-6b89d4c13d63/lib/rdf/rdfxml/reader/nokogiri.rb', line 253

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