module MARC::JRubySTAXReader
DEPRECATED: JRubySTAXReader
is deprecated and will be removed in a future version of ruby-marc. Please use NokogiriReader
instead.
Public Class Methods
extended(receiver)
click to toggle source
# File lib/marc/xml_parsers.rb, line 404 def self.extended(receiver) require "java" # may only be neccesary in jruby 1.6 receiver.init end
Public Instance Methods
attributes_to_hash(attributes)
click to toggle source
# File lib/marc/xml_parsers.rb, line 440 def attributes_to_hash(attributes) hash = {} @parser.getAttributeCount.times do |i| hash[@parser.getAttributeName(i).getLocalPart] = @parser.getAttributeValue(i) end hash end
each(&block)
click to toggle source
Loop through the MARC
records in the XML document
# File lib/marc/xml_parsers.rb, line 418 def each(&block) if block @block = block parser_dispatch else enum_for(:each) end end
init()
click to toggle source
Calls superclass method
MARC::GenericPullParser#init
# File lib/marc/xml_parsers.rb, line 409 def init warn "JRubySTAXReader is deprecated and will be removed in a future version of ruby-marc." super @factory = javax.xml.stream.XMLInputFactory.newInstance @parser = @factory.createXMLStreamReader(@handle.to_inputstream) end
parser_dispatch()
click to toggle source
# File lib/marc/xml_parsers.rb, line 427 def parser_dispatch while (event = @parser.next) && (event != javax.xml.stream.XMLStreamConstants::END_DOCUMENT) case event when javax.xml.stream.XMLStreamConstants::START_ELEMENT start_element_namespace(@parser.getLocalName, [], nil, @parser.getNamespaceURI, nil) when javax.xml.stream.XMLStreamConstants::END_ELEMENT end_element_namespace(@parser.getLocalName, @parser.getPrefix, @parser.getNamespaceURI) when javax.xml.stream.XMLStreamConstants::CHARACTERS characters(@parser.getText) end end end