Module: Transformator::FormatConverter

Includes:
DocumentFromHash, DocumentFromObject, DocumentFromXml, HashFromDocument, XmlFromDocument
Included in:
Transformator
Defined in:
lib/transformator/format_converter.rb

Defined Under Namespace

Modules: DocumentFromHash, DocumentFromObject, DocumentFromXml, HashFromDocument, XmlFromDocument

Class Method Summary collapse

Methods included from XmlFromDocument

#xml_from_document

Methods included from HashFromDocument

#hash_from_document, process_node

Methods included from DocumentFromXml

#document_from_xml

Methods included from DocumentFromObject

#document_from_object

Methods included from DocumentFromHash

#document_from_hash

Class Method Details

.remove_namespaces!(xml) ⇒ Object



14
15
16
# File 'lib/transformator/format_converter.rb', line 14

def self.remove_namespaces!(xml)
  xml.gsub!(/<(\/?)\w+:(\w+)/, "<\\1\\2")
end

.remove_whitespace_only_text_nodes(xml) ⇒ Object



18
19
20
# File 'lib/transformator/format_converter.rb', line 18

def self.remove_whitespace_only_text_nodes(xml)
  remove_whitespace_only_text_nodes!(xml.dup)
end

.remove_whitespace_only_text_nodes!(xml) ⇒ Object



22
23
24
25
26
# File 'lib/transformator/format_converter.rb', line 22

def self.remove_whitespace_only_text_nodes!(xml)
  # remove whitespace only text nodes
  xml.gsub!(/>(\s|\n|\r)+</, "><")
  xml
end