Class: ASpaceExport::RawXMLHandler

Inherits:
Object
  • Object
show all
Defined in:
backend/app/exporters/lib/streaming_xml.rb

Instance Method Summary (collapse)

Constructor Details

- (RawXMLHandler) initialize

Returns a new instance of RawXMLHandler



4
5
6
# File 'backend/app/exporters/lib/streaming_xml.rb', line 4

def initialize
  @fragments = {}
end

Instance Method Details

- (Object) <<(s)



8
9
10
11
12
# File 'backend/app/exporters/lib/streaming_xml.rb', line 8

def <<(s)
  id = SecureRandom.hex
  @fragments[id] = s
  ":aspace_fragment_#{id}"
end

- (Object) substitute_fragments(xml_string)



14
15
16
17
18
19
20
21
# File 'backend/app/exporters/lib/streaming_xml.rb', line 14

def substitute_fragments(xml_string)
  @fragments.each do |id, fragment|
    xml_string.gsub!(/:aspace_fragment_#{id}/, fragment)
    xml_string.gsub!(/[&]([^a])/, '&amp;\1')
  end

  xml_string
end