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

Defined in:
vendor/bundler/ruby/2.5.0/bundler/gems/rdf-rdfxml-68047f4a2915/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/2.5.0/bundler/gems/rdf-rdfxml-68047f4a2915/lib/rdf/rdfxml/reader/rexml.rb', line 14

def self.library
  :rexml
end

Instance Method Details

#doc_errorsObject

Document errors



278
279
280
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-rdfxml-68047f4a2915/lib/rdf/rdfxml/reader/rexml.rb', line 278

def doc_errors
  []
end

#initialize_xml(input, options = {})

This method returns an undefined value.

Initializes the underlying XML library.

Parameters:



248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-rdfxml-68047f4a2915/lib/rdf/rdfxml/reader/rexml.rb', line 248

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



272
273
274
# File 'vendor/bundler/ruby/2.5.0/bundler/gems/rdf-rdfxml-68047f4a2915/lib/rdf/rdfxml/reader/rexml.rb', line 272

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