Class: Nokogiri::XML::Element
- Inherits:
-
Object
- Object
- Nokogiri::XML::Element
- Defined in:
- lib/rdf/xsd/extensions.rb
Instance Method Summary collapse
-
#c14nxl(options = {}) ⇒ Object
Canonicalize the Element.
Instance Method Details
#c14nxl(options = {}) ⇒ Object
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.
60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
# File 'lib/rdf/xsd/extensions.rb', line 60 def c14nxl( = {}) [: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 [: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"] = [:language].to_s if [:language] && element.attribute_with_ns("lang", "http://www.w3.org/XML/1998/namespace").to_s.empty? && element.attribute("lang").to_s.empty? element end |