Class: EdifactConverter::EDI2XML11::XmlHandler
Defined Under Namespace
Classes: XmlElement
Instance Attribute Summary collapse
#locator, #next_handler
Instance Method Summary
collapse
#initialize, #method_missing
Instance Attribute Details
#current ⇒ Object
Returns the value of attribute current.
8
9
10
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 8
def current
@current
end
|
#document ⇒ Object
Returns the value of attribute document.
8
9
10
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 8
def document
@document
end
|
Instance Method Details
#endElement ⇒ Object
83
84
85
86
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 83
def endElement
self.current = current.parent
super
end
|
#endSegment(name) ⇒ Object
73
74
75
76
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 73
def endSegment(name)
self.current = self.current.parent
super
end
|
#endSegmentGroup(name) ⇒ Object
63
64
65
66
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 63
def endSegmentGroup(name)
self.current = current.parent
super
end
|
#startDocument ⇒ Object
46
47
48
49
|
# 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 ⇒ Object
78
79
80
81
|
# 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) ⇒ Object
68
69
70
71
|
# 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) ⇒ Object
58
59
60
61
|
# 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) ⇒ Object
88
89
90
91
92
|
# 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)
super
end
|
#xml ⇒ Object
94
95
96
97
98
99
100
101
102
103
104
|
# File 'lib/edifact_converter/edi2xml11/xml_handler.rb', line 94
def xml
builder = Nokogiri::XML::Builder.new(:encoding => 'ISO-8859-1') do |xml|
xml. "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
|