~ubuntu-branches/ubuntu/hardy/ruby1.8/hardy-updates

« back to all changes in this revision

Viewing changes to lib/xsd/xmlparser/rexmlparser.rb

  • Committer: Bazaar Package Importer
  • Author(s): akira yamada
  • Date: 2007-03-13 22:11:58 UTC
  • mfrom: (1.1.5 upstream)
  • Revision ID: james.westby@ubuntu.com-20070313221158-h3oql37brlaf2go2
Tags: 1.8.6-1
* new upstream version, 1.8.6.
* libruby1.8 conflicts with libopenssl-ruby1.8 (< 1.8.6) (closes: #410018)
* changed packaging style to cdbs from dbs.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# XSD4R - REXMLParser XML parser library.
 
2
# Copyright (C) 2002, 2003  NAKAMURA, Hiroshi <nahi@ruby-lang.org>.
 
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'
 
10
require 'rexml/streamlistener'
 
11
require 'rexml/document'
 
12
 
 
13
 
 
14
module XSD
 
15
module XMLParser
 
16
 
 
17
 
 
18
class REXMLParser < XSD::XMLParser::Parser
 
19
  include REXML::StreamListener
 
20
 
 
21
  def do_parse(string_or_readable)
 
22
    source = nil
 
23
    source = REXML::SourceFactory.create_from(string_or_readable)
 
24
    source.encoding = charset if charset
 
25
    # Listener passes a String in utf-8.
 
26
    @charset = 'utf-8'
 
27
    REXML::Document.parse_stream(source, self)
 
28
  end
 
29
 
 
30
  def epilogue
 
31
  end
 
32
 
 
33
  def tag_start(name, attrs)
 
34
    start_element(name, attrs)
 
35
  end
 
36
 
 
37
  def tag_end(name)
 
38
    end_element(name)
 
39
  end
 
40
 
 
41
  def text(text)
 
42
    characters(text)
 
43
  end
 
44
 
 
45
  def xmldecl(version, encoding, standalone)
 
46
    # Version should be checked.
 
47
  end
 
48
 
 
49
  add_factory(self)
 
50
end
 
51
 
 
52
 
 
53
end
 
54
end