Class: Nokogiri::XML::Node

Inherits:
Object show all
Defined in:
vendor/bundler/ruby/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/lib/rdf/xsd/extensions.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 https://www.w3.org/TR/xml-exc-c14n/

Instance Method Summary collapse

Instance Method Details

#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/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/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/3.3.0/bundler/gems/rdf-xsd-1663b6f0e598/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