class EdifactConverter::EDI2XML11::XmlHandler

Attributes

current[RW]
document[RW]

Public Instance Methods

endDocument() click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 51
def endDocument
  unless current == document
    raise EdifactConverter::EdifactError.new "Internal Error, please report to jacob@medware.dk", Position.new(0,0)
  end
  super
end
endElement() click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 83
def endElement
  self.current = current.parent
  super
end
endSegment(name) click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 73
def endSegment(name)
  self.current = self.current.parent
  super
end
endSegmentGroup(name) click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 63
def endSegmentGroup(name)
  self.current = current.parent
  super
end
startDocument() click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 46
def startDocument
  self.document = self.current = XmlElement.new name: 'Edifact', position: Position.new(0, 0)
  super
end
startElement() click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 78
def startElement
  self.current = XmlElement.new name: 'Elm', position: locator.position, parent: current
  super
end
startSegment(name) click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 68
def startSegment(name)
  self.current = XmlElement.new name: name.encode(Encoding::UTF_8), position: locator.position, parent: current
  super
end
startSegmentGroup(name, hidden = false) click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 58
def startSegmentGroup(name, hidden = false)
  self.current = XmlElement.new name: name.encode(Encoding::UTF_8), position: locator.position, parent: current, hidden: hidden
  super
end
value(value) click to toggle source
Calls superclass method
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 88
def value(value)
  XmlElement.new name: 'SubElm', position: locator.position, parent: current, text: value.encode(Encoding::UTF_8)
  #val.text = value.encode(Encoding::UTF_8)
  super
end
xml() click to toggle source
# File lib/edifact_converter/edi2xml11/xml_handler.rb, line 94
def xml
  builder = Nokogiri::XML::Builder.new(:encoding => 'ISO-8859-1') do |xml|
    xml.comment "Created from Edifact at #{Time.now.utc}"
    document.render xml
  end
  xml = builder.doc
  xml.xpath("//Elm").each do |elm|
    elm.children.last.remove if elm.children.last.content == ""
  end
  xml
end