Sha256: d28b056b428d0d94c7a8fe661e523d1c477112e469eb538f3cdc34f11102b744

Contents?: true

Size: 970 Bytes

Versions: 13

Compression:

Stored size: 970 Bytes

Contents

require 'nokogiri'
class Nokogiri::XML::Node
  # URI of namespace + node_name
  def uri
    ns = self.namespace ? self.namespace.href : RDF::XML.to_s
    RDF::URI.intern(ns + self.node_name)
  end

  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 && parent.display_path}@#{name}"
    end
  end
  
  alias_method :attribute_with_ns_without_ffi_null, :attribute_with_ns
  ##
  # Monkey patch attribute_with_ns, to insure nil is returned for #null?
  #
  # Get the attribute node with name and namespace
  #
  # @param [String] name
  # @param [String] namespace
  # @return [Nokogiri::XML::Attr]
  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
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
rdf-rdfxml-1.1.2 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.1.1 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.1.0.1 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.1.0 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.0.3 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.1.0p0 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.0.2 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.0.1 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-1.0.0 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-0.3.9 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-0.3.8 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-0.3.7 lib/rdf/rdfxml/patches/nokogiri_hacks.rb
rdf-rdfxml-0.3.6 lib/rdf/rdfxml/patches/nokogiri_hacks.rb