Class: Nokogiri::XML::Node

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-xsd-ec78ebe10f85/lib/rdf/xsd/extensions.rb,
vendor/bundler/ruby/2.4.0/bundler/gems/rdf-rdfxml-5324e00a23df/lib/rdf/rdfxml/patches/nokogiri_hacks.rb

Overview

XML Exclusive Canonicalization (c14n) for Nokogiri.

Classes mixin this module to implement canonicalization methods.

This implementation acts in two parts, first to canonicalize the Node or NoteSet in the context of its containing document, and second to serialize to a lexical representation.

See Also:

  • @see http://www.w3.org/TR/xml-exc-c14n/

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:

Returns:

  • (Nokogiri::XML::Attr)


18
19
20
21
22
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-rdfxml-5324e00a23df/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 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-rdfxml-5324e00a23df/lib/rdf/rdfxml/patches/nokogiri_hacks.rb', line 9

alias_method :attribute_with_ns_without_ffi_null, :attribute_with_ns

#c14nxl(options = {}) ⇒ Object

Canonicalize the Node. Return a new instance of this node which is canonicalized and marked as such

Parameters:

Options Hash (options):

  • :namespaces (Hash{String => String})

    Namespaces to apply to node.

  • :language (#to_s)

    Language to set on node, unless an xml:lang is already set.



29
30
31
32
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-xsd-ec78ebe10f85/lib/rdf/xsd/extensions.rb', line 29

def c14nxl(options = {})
  @c14nxl = true
  self
end

#to_s_with_c14nxlObject Also known as: to_s

Serialize a canonicalized Node or NodeSet to XML

Override standard #to_s implementation to output in c14n representation if the Node or NodeSet is marked as having been canonicalized



39
40
41
42
43
44
45
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-xsd-ec78ebe10f85/lib/rdf/xsd/extensions.rb', line 39

def to_s_with_c14nxl
  if instance_variable_defined?(:@c14nxl)
    serialize(:save_with => ::Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)
  else
    to_s_without_c14nxl
  end
end

#uriObject

URI of namespace + node_name



4
5
6
7
# File 'vendor/bundler/ruby/2.4.0/bundler/gems/rdf-rdfxml-5324e00a23df/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