Module: XSD::XMLParser

Defined in:
lib/xsd/xmlparser.rb,
lib/xsd/xmlparser/parser.rb,
lib/xsd/xmlparser/xmlparser.rb,
lib/xsd/xmlparser/xmlscanner.rb,
lib/xsd/xmlparser/rexmlparser.rb,
lib/xsd/xmlparser/libxmlparser.rb

Defined Under Namespace

Classes: LibXMLParser, Parser, REXMLParser, XMLParser, XMLScanner

Constant Summary collapse

NSParseRegexp =

$1 is necessary.

Regexp.new('^xmlns:?(.*)$', nil, 'NONE')

Class Method Summary collapse

Class Method Details

.create_parser(host, opt) ⇒ Object



16
17
18
# File 'lib/xsd/xmlparser.rb', line 16

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

.filter_ns(ns, attrs) ⇒ Object



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
# File 'lib/xsd/xmlparser.rb', line 24

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