Module: RDF::RDFXML::Reader::REXML

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

Overview

REXML implementation of an XML parser.

Defined Under Namespace

Classes: Namespace, NodeProxy, NodeSetProxy

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.librarySymbol

Returns the name of the underlying XML library.

Returns:



14
15
16
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/rexml.rb', line 14

def self.library
  :rexml
end

Instance Method Details

#doc_errorsObject

Document errors



306
307
308
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/rexml.rb', line 306

def doc_errors
  []
end

#initialize_xml(input, **options)

This method returns an undefined value.

Initializes the underlying XML library.

Parameters:



276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/rexml.rb', line 276

def initialize_xml(input, **options)
  require 'rexml/document' unless defined?(::REXML)
  @doc = case input
  when ::REXML::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'

    # Set xml:base for the document element, if defined
    @base_uri = base_uri ? base_uri.to_s : nil

    # Only parse as XML, no HTML mode
    ::REXML::Document.new(input.respond_to?(:read) ? input.read : input.to_s)
  end
end

#rootObject

Return proxy for document root



300
301
302
# File 'vendor/bundler/ruby/3.4.0/bundler/gems/rdf-rdfxml-14ee5432437b/lib/rdf/rdfxml/reader/rexml.rb', line 300

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