Class: Nokogiri::XML::Node

Inherits:
Object
  • Object
show all
Defined in:
lib/rdf/rdfxml/patches/nokogiri_hacks.rb

Instance Method Summary collapse

Instance Method Details

#attribute_with_ns(name, namespace) ⇒ Nokogiri::XML::Attr

Monkey patch attribute_with_ns, to insure nil is returned for #null?

Get the attribute node with name and namespace

Parameters:

  • name (String)
  • namespace (String)

Returns:

  • (Nokogiri::XML::Attr)


26
27
28
29
30
# File 'lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 26

def attribute_with_ns(name, namespace)
  a = attribute_with_ns_without_ffi_null(name, namespace)
  
  (a.respond_to?(:null?) && a.null?) ? nil : a # to ensure FFI Pointer compatibility
end

#attribute_with_ns_without_ffi_nullObject



17
# File 'lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 17

alias_method :attribute_with_ns_without_ffi_null, :attribute_with_ns

#display_pathObject



9
10
11
12
13
14
15
# File 'lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 9

def display_path
  @display_path ||= case self
  when Nokogiri::XML::Document then ""
  when Nokogiri::XML::Element then parent ? "#{parent.display_path}/#{name}" : name
  when Nokogiri::XML::Attr then "#{parent.display_path}@#{name}"
  end
end

#uriObject

URI of namespace + node_name



4
5
6
7
# File 'lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 4

def uri
  ns = self.namespace ? self.namespace.href : RDF::XML.to_s
  RDF::URI.intern(ns + self.node_name)
end