Rev | Line | |
---|
[18425] | 1 | # XSD4R - XML Instance parser library.
|
---|
| 2 | # Copyright (C) 2002, 2003 NAKAMURA, Hiroshi <[email protected]>.
|
---|
| 3 |
|
---|
| 4 | # This program is copyrighted free software by NAKAMURA, Hiroshi. You can
|
---|
| 5 | # redistribute it and/or modify it under the same terms of Ruby's license;
|
---|
| 6 | # either the dual license version in 2003, or any later version.
|
---|
| 7 |
|
---|
| 8 |
|
---|
| 9 | require 'xsd/xmlparser/parser'
|
---|
| 10 |
|
---|
| 11 |
|
---|
| 12 | module XSD
|
---|
| 13 |
|
---|
| 14 |
|
---|
| 15 | module XMLParser
|
---|
| 16 | def create_parser(host, opt)
|
---|
| 17 | XSD::XMLParser::Parser.create_parser(host, opt)
|
---|
| 18 | end
|
---|
| 19 | module_function :create_parser
|
---|
| 20 |
|
---|
| 21 | # $1 is necessary.
|
---|
| 22 | NSParseRegexp = Regexp.new('^xmlns:?(.*)$')
|
---|
| 23 |
|
---|
| 24 | def filter_ns(ns, attrs)
|
---|
| 25 | return attrs if attrs.nil? or attrs.empty?
|
---|
| 26 | newattrs = {}
|
---|
| 27 | attrs.each do |key, value|
|
---|
| 28 | if (NSParseRegexp =~ key)
|
---|
| 29 | # '' means 'default namespace'.
|
---|
| 30 | tag = $1 || ''
|
---|
| 31 | ns.assign(value, tag)
|
---|
| 32 | else
|
---|
| 33 | newattrs[key] = value
|
---|
| 34 | end
|
---|
| 35 | end
|
---|
| 36 | newattrs
|
---|
| 37 | end
|
---|
| 38 | module_function :filter_ns
|
---|
| 39 | end
|
---|
| 40 |
|
---|
| 41 |
|
---|
| 42 | end
|
---|
| 43 |
|
---|
| 44 |
|
---|
| 45 | # Try to load XML processor.
|
---|
| 46 | loaded = false
|
---|
| 47 | [
|
---|
| 48 | 'xsd/xmlparser/xmlparser',
|
---|
| 49 | 'xsd/xmlparser/xmlscanner',
|
---|
| 50 | 'xsd/xmlparser/rexmlparser',
|
---|
| 51 | ].each do |lib|
|
---|
| 52 | begin
|
---|
| 53 | require lib
|
---|
| 54 | loaded = true
|
---|
| 55 | break
|
---|
| 56 | rescue LoadError
|
---|
| 57 | end
|
---|
| 58 | end
|
---|
| 59 | unless loaded
|
---|
| 60 | raise RuntimeError.new("XML processor module not found.")
|
---|
| 61 | end
|
---|
Note:
See
TracBrowser
for help on using the repository browser.