module PIM::XML::DefaultTransform

Constants

PIM_CONTENT_TYPE
PIM_ROOT_ELEMENTS

Public Class Methods

extended(base) click to toggle source
# File xml/helpers.rb, line 156
def self.extended base
  # Add 'Parameters' module
  base.extend PIM::XML::Parameters
end

Public Instance Methods

element_handler(node)
Alias for: pim_element_handler
end()
Alias for: pim_end
handler(name)
Alias for: pim_handler
intercept_end_element(name, *args)
intercept_start_element(name, *args)
pim_element_handler(node) click to toggle source
# File xml/helpers.rb, line 141
def pim_element_handler node
  if @is_pim_xml
    @output.element node.name do
      node.attributes.each do |name, attribute|
        @output.attribute name, attribute.value
      end
      output_location_attribute if node.name == 'item'
      apply node.children
    end
  else
    default_element_handler(node)
  end
end
Also aliased as: element_handler
pim_end() click to toggle source
# File xml/helpers.rb, line 81
def pim_end
  @output.writer.end_element_namespace 'pim' if @pim_write_start_end_tags
end
Also aliased as: end
pim_handler(name) click to toggle source

Disable default “handler” for the internal format, because no transformation is necessary

# File xml/helpers.rb, line 132
def pim_handler name
  if @is_pim_xml
    return nil
  else
    return default_handler(name)
  end
end
Also aliased as: handler
pim_intercept_end_element(name, *args) click to toggle source
# File xml/helpers.rb, line 99
def pim_intercept_end_element name, *args

  if @is_pim_xml and intercept_depth == 0 and PIM_ROOT_ELEMENTS.include?(name)
    @is_pim_xml = false
    set_number_of_items(@pim_item_counter)
  end

  default_intercept_end_element(name, *args)

end
Also aliased as: intercept_end_element
pim_intercept_start_element(name, *args) click to toggle source
# File xml/helpers.rb, line 86
def pim_intercept_start_element name, *args

  default_intercept_start_element(name, *args)

  if not @is_pim_xml and intercept_depth == 0 and PIM_ROOT_ELEMENTS.include?(name)
    @is_pim_xml = true
    @pim_item_counter = 0
    set_content_type(PIM_CONTENT_TYPE)
  end

end
Also aliased as: intercept_start_element
pim_split?(element) click to toggle source
# File xml/helpers.rb, line 111
def pim_split? element

  # Only split when we the root element was matched and we reached the 'right' depth
  return false unless @is_pim_xml and intercept_depth == 1

  # Immediately split on these non 'item' elements
  return true if ['response', 'review'].include?(element.name)

  # Only split on 'item' elements
  return false unless element.name == 'item'

  # Count the 'item' element
  @pim_item_counter += 1

  # Check if item is in chunk range
  return is_in_chunk_range? current_item: (@pim_item_counter - 1)

end
Also aliased as: split?
pim_start() click to toggle source
# File xml/helpers.rb, line 71
def pim_start

  # Only write out start-end tags, if the "active" transformer did not write them itself!
  # Otherwise we would accidentally write out double "<pim>" tags.
  @pim_write_start_end_tags = (@output.writer.depth < 0)
  @output.writer.start_element_namespace 'pim', [] if @pim_write_start_end_tags

end
Also aliased as: start
split?(element)
Alias for: pim_split?
start()
Alias for: pim_start