class Nokogiri::XML::Element
Public Instance Methods
c14nxl(options = {})
click to toggle source
Canonicalize the Element
. Return a new instance of this node which is canonicalized and marked as such.
Apply namespaces either passed as an option, or that are in scope.
@param [Hash{Symbol => Object}] options
From {Nokogiri::XML::Node#c14nxl}
# File lib/rdf/xsd/extensions.rb, line 60 def c14nxl(options = {}) options[:namespaces] ||= self.namespace_scopes.compact.inject({}) do |memo, ns| memo[ns.prefix] = ns.href.to_s memo end element = self.clone # Add in-scope namespace definitions options[:namespaces].each do |prefix, href| if prefix.to_s.empty? element.default_namespace = href unless element.namespace else element.add_namespace(prefix.to_s, href) unless element.namespaces[prefix.to_s] end end # Add language element["xml:lang"] = options[:language].to_s if options[:language] && element.attribute_with_ns("lang", "http://www.w3.org/XML/1998/namespace").to_s.empty? && element.attribute("lang").to_s.empty? element end