Class: Nokogiri::XML::NodeSet

Inherits:
Object
  • Object
show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb

Instance Method Summary collapse

Instance Method Details

#c14nxl(options = {}) ⇒ Object

Canonicalize the NodeSet. Return a new NodeSet marked as being canonical with all child nodes canonicalized.

Parameters:

  • options (Hash{Symbol => Object}) (defaults to: {})

    Passed to Nokogiri::XML::Node#c14nxl



93
94
95
96
97
98
99
100
101
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb', line 93

def c14nxl(options = {})
  # Create a new NodeSet
  set = self.dup
  set.pop while !set.empty?
  set.instance_variable_set(:@c14nxl, true)

  self.each {|c| set << c.c14nxl(options)}
  set
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



108
109
110
111
112
113
114
# File 'vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.rb', line 108

def to_s_with_c14nxl
  if instance_variable_defined?(:@c14nxl)
    to_a.map {|c| c.serialize(:save_with => ::Nokogiri::XML::Node::SaveOptions::NO_EMPTY_TAGS)}.join("")
  else
    to_s_without_c14nxl
  end
end