Class: LibXMLJRuby::XML::Parser
- Inherits:
-
Object
- Object
- LibXMLJRuby::XML::Parser
- Defined in:
- lib/libxml-jruby/xml/parser.rb
Defined Under Namespace
Classes: ParseError
Constant Summary collapse
- VERNUM =
0
- VERSION =
'0'
Class Attribute Summary collapse
-
.check_lib_versions ⇒ Object
Returns the value of attribute check_lib_versions.
-
.debug_entities ⇒ Object
Returns the value of attribute debug_entities.
-
.default_compression ⇒ Object
Returns the value of attribute default_compression.
-
.default_keep_blanks ⇒ Object
Returns the value of attribute default_keep_blanks.
-
.default_line_numbers ⇒ Object
Returns the value of attribute default_line_numbers.
-
.default_substitute_entities ⇒ Object
Returns the value of attribute default_substitute_entities.
-
.default_tree_indent_string ⇒ Object
Returns the value of attribute default_tree_indent_string.
-
.default_validity_checking ⇒ Object
Returns the value of attribute default_validity_checking.
-
.default_warnings ⇒ Object
Returns the value of attribute default_warnings.
-
.features ⇒ Object
Returns the value of attribute features.
-
.indent_tree_output ⇒ Object
Returns the value of attribute indent_tree_output.
Instance Attribute Summary collapse
-
#filename ⇒ Object
Returns the value of attribute filename.
-
#io ⇒ Object
Returns the value of attribute io.
-
#string ⇒ Object
Returns the value of attribute string.
Class Method Summary collapse
- .file(filename) ⇒ Object
- .io(io) ⇒ Object
- .register_error_handler(handler = nil, &block) ⇒ Object
- .string(string) ⇒ Object
Instance Method Summary collapse
- #document_builder ⇒ Object
- #document_builder_factory ⇒ Object
-
#initialize ⇒ Parser
constructor
A new instance of Parser.
- #input_source ⇒ Object
- #parse ⇒ Object
- #parse_file ⇒ Object
- #parse_io ⇒ Object
- #parse_string ⇒ Object
- #string_reader ⇒ Object
Constructor Details
#initialize ⇒ Parser
Returns a new instance of Parser.
43 44 45 46 |
# File 'lib/libxml-jruby/xml/parser.rb', line 43 def initialize @source_type = nil @parsed = false end |
Class Attribute Details
.check_lib_versions ⇒ Object
Returns the value of attribute check_lib_versions.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def check_lib_versions @check_lib_versions end |
.debug_entities ⇒ Object
Returns the value of attribute debug_entities.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def debug_entities @debug_entities end |
.default_compression ⇒ Object
Returns the value of attribute default_compression.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_compression @default_compression end |
.default_keep_blanks ⇒ Object
Returns the value of attribute default_keep_blanks.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_keep_blanks @default_keep_blanks end |
.default_line_numbers ⇒ Object
Returns the value of attribute default_line_numbers.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_line_numbers @default_line_numbers end |
.default_substitute_entities ⇒ Object
Returns the value of attribute default_substitute_entities.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_substitute_entities @default_substitute_entities end |
.default_tree_indent_string ⇒ Object
Returns the value of attribute default_tree_indent_string.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_tree_indent_string @default_tree_indent_string end |
.default_validity_checking ⇒ Object
Returns the value of attribute default_validity_checking.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_validity_checking @default_validity_checking end |
.default_warnings ⇒ Object
Returns the value of attribute default_warnings.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def default_warnings @default_warnings end |
.features ⇒ Object
Returns the value of attribute features.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def features @features end |
.indent_tree_output ⇒ Object
Returns the value of attribute indent_tree_output.
12 13 14 |
# File 'lib/libxml-jruby/xml/parser.rb', line 12 def indent_tree_output @indent_tree_output end |
Instance Attribute Details
#filename ⇒ Object
Returns the value of attribute filename.
48 49 50 |
# File 'lib/libxml-jruby/xml/parser.rb', line 48 def filename @filename end |
#io ⇒ Object
Returns the value of attribute io.
48 49 50 |
# File 'lib/libxml-jruby/xml/parser.rb', line 48 def io @io end |
#string ⇒ Object
Returns the value of attribute string.
48 49 50 |
# File 'lib/libxml-jruby/xml/parser.rb', line 48 def string @string end |
Class Method Details
.file(filename) ⇒ Object
24 25 26 27 28 |
# File 'lib/libxml-jruby/xml/parser.rb', line 24 def file(filename) p = new p.filename = filename p end |
.io(io) ⇒ Object
36 37 38 39 40 |
# File 'lib/libxml-jruby/xml/parser.rb', line 36 def io(io) p = new p.io = io p end |
.register_error_handler(handler = nil, &block) ⇒ Object
20 21 22 |
# File 'lib/libxml-jruby/xml/parser.rb', line 20 def register_error_handler(handler = nil, &block) end |
.string(string) ⇒ Object
30 31 32 33 34 |
# File 'lib/libxml-jruby/xml/parser.rb', line 30 def string(string) p = new p.string = string p end |
Instance Method Details
#document_builder ⇒ Object
80 81 82 83 |
# File 'lib/libxml-jruby/xml/parser.rb', line 80 def document_builder document_builder_factory.namespace_aware = true document_builder_factory.new_document_builder end |
#document_builder_factory ⇒ Object
76 77 78 |
# File 'lib/libxml-jruby/xml/parser.rb', line 76 def document_builder_factory @dbf ||= DocumentBuilderFactory.new_instance end |
#input_source ⇒ Object
89 90 91 |
# File 'lib/libxml-jruby/xml/parser.rb', line 89 def input_source InputSource.new(string_reader) end |
#parse ⇒ Object
68 69 70 71 72 73 74 |
# File 'lib/libxml-jruby/xml/parser.rb', line 68 def parse raise ParseError, "You cannot parse twice" if @parsed raise ParseError, "No input specified, please specify an input" unless @source_type doc = send("parse_#{@source_type.to_s.downcase}") @parsed = true doc end |
#parse_file ⇒ Object
106 107 108 109 110 111 112 113 114 115 116 |
# File 'lib/libxml-jruby/xml/parser.rb', line 106 def parse_file builder = document_builder begin jdoc = builder.parse(@filename) rescue raise ParseError end LibXMLJRuby::XML::Document.from_java(jdoc) end |
#parse_io ⇒ Object
118 119 120 |
# File 'lib/libxml-jruby/xml/parser.rb', line 118 def parse_io parse_string end |
#parse_string ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 |
# File 'lib/libxml-jruby/xml/parser.rb', line 93 def parse_string raise ParseError if @string.empty? builder = document_builder begin jdoc = builder.parse(input_source) rescue NativeException raise ParseError end LibXMLJRuby::XML::Document.from_java(jdoc) end |
#string_reader ⇒ Object
85 86 87 |
# File 'lib/libxml-jruby/xml/parser.rb', line 85 def string_reader StringReader.new(@string) end |