Sha256: 09612f68dc9caef196dbba1b3547e2fb1a5aa3b4cf4ceaadcf7378705938cdf0

Contents?: true

Size: 1.64 KB

Versions: 38

Compression:

Stored size: 1.64 KB

Contents

# encoding: ASCII-8BIT
# XSD4R - XML Instance parser library.
# Copyright (C) 2000-2007  NAKAMURA, Hiroshi <nahi@ruby-lang.org>.

# This program is copyrighted free software by NAKAMURA, Hiroshi.  You can
# redistribute it and/or modify it under the same terms of Ruby's license;
# either the dual license version in 2003, or any later version.


require 'xsd/xmlparser/parser'


module XSD


module XMLParser
  def create_parser(host, opt)
    XSD::XMLParser::Parser.create_parser(host, opt)
  end
  module_function :create_parser

  # $1 is necessary.
  NSParseRegexp = Regexp.new('^xmlns:?(.*)$', nil, 'n')

  def filter_ns(ns, attrs)
    ns_updated = false
    if attrs.nil? or attrs.empty?
      return [ns, attrs]
    end
    newattrs = {}
    attrs.each do |key, value|
      if NSParseRegexp =~ key
        unless ns_updated
          ns = ns.clone_ns
          ns_updated = true
        end
	# tag == '' means 'default namespace'
        # value == '' means 'no default namespace'
	tag = $1 || ''
	ns.assign(value, tag)
      else
	newattrs[key] = value
      end
    end
    return [ns, newattrs]
  end
  module_function :filter_ns
end


end


# Try to load XML processor.
loaded = false
[
  'nokogiri',
#  'libxmlparser',
#  'xmlparser',
#  'xmlscanner',
  'rexmlparser',
].each do |name|
  begin
    require "xsd/xmlparser/#{name}"
    # XXX: for a workaround of rubygems' require inconsistency
    # XXX: MUST BE REMOVED IN THE FUTURE
    raise LoadError unless XSD::XMLParser.constants.find { |c|
      c.to_s.downcase == name
    }
    loaded = true
    break
  rescue LoadError
  end
end
unless loaded
  raise RuntimeError.new("XML processor module not found.")
end

Version data entries

38 entries across 38 versions & 10 rubygems

Version Path
soybean-2.5.5 vendor/soap4r/xsd/xmlparser.rb
malagant-soap4r-1.5.8.20141127181857 lib/xsd/xmlparser.rb
rtiss_soap4r-1.6.1 lib/xsd/xmlparser.rb
rtiss_soap4r-1.6.0 lib/xsd/xmlparser.rb
eSpace_soap4r-1.5.8 lib/xsd/xmlparser.rb
soap4r-ruby19-1.5.9 lib/xsd/xmlparser.rb
tomdz-soap4r-1.5.8.20120202093209 lib/xsd/xmlparser.rb
soap5r-2.0.3 lib/xsd/xmlparser.rb
soap5r-2.0.2 lib/xsd/xmlparser.rb
soap5r-2.0.1 lib/xsd/xmlparser.rb
soap5r-2.0.0 lib/xsd/xmlparser.rb
soap5r-2.0.0.20120130130121 lib/xsd/xmlparser.rb
soap4r-sgonyea-1.5.9 lib/xsd/xmlparser.rb
sunteya-soap4r-1.5.8.0 lib/xsd/xmlparser.rb
soybean-2.5.4 vendor/soap4r/xsd/xmlparser.rb
tomdz-soap4r-1.5.8.20111103171510 lib/xsd/xmlparser.rb
soybean-2.5.3 vendor/soap4r/xsd/xmlparser.rb
soybean-2.5.2 vendor/soap4r/xsd/xmlparser.rb
soybean-2.5.1 vendor/soap4r/xsd/xmlparser.rb
soybean-2.5.0 vendor/soap4r/xsd/xmlparser.rb