W3cubDocs

/Nokogiri

class XSD::XMLParser::Nokogiri

Parent:
XSD::XMLParser::Parser

Nokogiri XML parser for soap4r.

Nokogiri may be used as the XML parser in soap4r. Simply require ‘xsd/xmlparser/nokogiri’ in your soap4r applications, and soap4r will use Nokogiri as it’s XML parser. No other changes should be required to use Nokogiri as the XML parser.

Example (using UW ITS Web Services):

require 'rubygems'
require 'nokogiri'
gem 'soap4r'
require 'defaultDriver'
require 'xsd/xmlparser/nokogiri'

obj = AvlPortType.new
obj.getLatestByRoute(obj.getAgencies.first, 8).each do |bus|
  p "#{bus.routeID}, #{bus.longitude}, #{bus.latitude}"
end

Public Class Methods

new(host, opt = {}) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 31
def initialize(host, opt = {})
  super
  @parser = ::Nokogiri::XML::SAX::Parser.new(self, @charset || "UTF-8")
end

Create a new XSD parser with host and opt

Calls superclass method

Public Instance Methods

cdata_block(string) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 63
def cdata_block(string)
  characters(string)
end

Handle cdata_blocks containing string

do_parse(string_or_readable) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 38
def do_parse(string_or_readable)
  @parser.parse(string_or_readable)
end

Start parsing string_or_readable

end_element(name) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 50
def end_element(name)
  super
end

Handle the end_element event with name

Calls superclass method
end_element_namespace(name, prefix = nil, uri = nil) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 91
def end_element_namespace(name, prefix = nil, uri = nil)
  ###
  # Deal with SAX v1 interface
  end_element([prefix, name].compact.join(":"))
end

Called at the end of an element name is the element’s name prefix is the namespace prefix associated with the element uri is the associated namespace URI

error(msg) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 56
def error(msg)
  raise ParseError, msg
end

Handle errors with message msg

Also aliased as: warning
start_element(name, attrs = []) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 44
def start_element(name, attrs = [])
  super(name, Hash[*attrs.flatten])
end

Handle the start_element event with name and attrs

Calls superclass method
start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = []) Show source
# File lib/xsd/xmlparser/nokogiri.rb, line 74
def start_element_namespace(name, attrs = [], prefix = nil, uri = nil, ns = [])
  ###
  # Deal with SAX v1 interface
  name = [prefix, name].compact.join(":")
  attributes = ns.map do |ns_prefix, ns_uri|
    [["xmlns", ns_prefix].compact.join(":"), ns_uri]
  end + attrs.map do |attr|
    [[attr.prefix, attr.localname].compact.join(":"), attr.value]
  end.flatten
  start_element(name, attributes)
end

Called at the beginning of an element name is the element name attrs is a list of attributes prefix is the namespace prefix for the element uri is the associated namespace URI ns is a hash of namespace prefix:urls associated with the element

warning(msg)
Alias for: error

© 2008–2018 Aaron Patterson, Mike Dalessio, Charles Nutter, Sergio Arbeo,
Patrick Mahoney, Yoko Harada, Akinori MUSHA, John Shahid, Lars Kanis
Licensed under the MIT License.
https://nokogiri.org/rdoc/XSD/XMLParser/Nokogiri.html