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)


18
19
20
21
22
# File 'lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 18

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



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

alias_method :attribute_with_ns_without_ffi_null, :attribute_with_ns

#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