Class: InformationCard::XmlCanonicalizer
- Inherits:
-
Object
- Object
- InformationCard::XmlCanonicalizer
- Defined in:
- lib/vendor/information_card/xml_canonicalizer.rb
Instance Method Summary collapse
- #canonicalize(element) ⇒ Object
-
#initialize ⇒ XmlCanonicalizer
constructor
A new instance of XmlCanonicalizer.
Constructor Details
#initialize ⇒ XmlCanonicalizer
Returns a new instance of XmlCanonicalizer.
7 8 9 |
# File 'lib/vendor/information_card/xml_canonicalizer.rb', line 7 def initialize @canonicalized_xml = '' end |
Instance Method Details
#canonicalize(element) ⇒ Object
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/vendor/information_card/xml_canonicalizer.rb', line 11 def canonicalize(element) document = REXML::Document.new(element.to_s) #TODO: Do we need this check? if element.instance_of?(REXML::Element) namespace = element.namespace(element.prefix) if not namespace.empty? if not element.prefix.empty? document.root.add_namespace(element.prefix, namespace) else document.root.add_namespace(namespace) end end end document.each_child{ |node| write_node(node, nil) } @canonicalized_xml.strip end |