Class: LibXMLJRuby::XML::Document
- Inherits:
-
Object
- Object
- LibXMLJRuby::XML::Document
- Defined in:
- lib/libxml-jruby/xml/document.rb
Instance Attribute Summary collapse
-
#java_obj ⇒ Object
org.w3c.dom.Document.
Class Method Summary collapse
Instance Method Summary collapse
- #child? ⇒ Boolean
- #find(expr, nslist = nil) ⇒ Object
- #find_first(expr, nslist = nil) ⇒ Object
-
#initialize(xml_version = 1.0) ⇒ Document
constructor
A new instance of Document.
- #parent? ⇒ Boolean
- #root ⇒ Object
- #validate(dtd) ⇒ Object
Constructor Details
#initialize(xml_version = 1.0) ⇒ Document
Returns a new instance of Document.
22 23 24 25 |
# File 'lib/libxml-jruby/xml/document.rb', line 22 def initialize(xml_version = 1.0) @xml_version = xml_version @xpath_cache = {} end |
Instance Attribute Details
#java_obj ⇒ Object
org.w3c.dom.Document
20 21 22 |
# File 'lib/libxml-jruby/xml/document.rb', line 20 def java_obj @java_obj end |
Class Method Details
.file(filename) ⇒ Object
5 6 7 |
# File 'lib/libxml-jruby/xml/document.rb', line 5 def file(filename) LibXMLJRuby::XML::Parser.file(filename).parse end |
.from_java(java_obj) ⇒ Object
13 14 15 16 17 |
# File 'lib/libxml-jruby/xml/document.rb', line 13 def from_java(java_obj) d = new d.java_obj = java_obj d end |
.string(str) ⇒ Object
9 10 11 |
# File 'lib/libxml-jruby/xml/document.rb', line 9 def string(str) LibXMLJRuby::XML::Parser.string(str).parse end |
Instance Method Details
#child? ⇒ Boolean
39 40 41 |
# File 'lib/libxml-jruby/xml/document.rb', line 39 def child? java_obj.hasChildNodes end |
#find(expr, nslist = nil) ⇒ Object
31 32 33 |
# File 'lib/libxml-jruby/xml/document.rb', line 31 def find(expr, nslist = nil) @xpath_cache[[expr, nslist]] ||= LibXMLJRuby::XML::XPath::Object.new(expr, self, nslist) end |
#find_first(expr, nslist = nil) ⇒ Object
35 36 37 |
# File 'lib/libxml-jruby/xml/document.rb', line 35 def find_first(expr, nslist = nil) find(expr, nslist).first end |
#parent? ⇒ Boolean
43 44 45 |
# File 'lib/libxml-jruby/xml/document.rb', line 43 def parent? !!java_obj.parent_node end |
#root ⇒ Object
47 48 49 |
# File 'lib/libxml-jruby/xml/document.rb', line 47 def root @root ||= Node.from_java(java_obj.document_element) end |
#validate(dtd) ⇒ Object
27 28 29 |
# File 'lib/libxml-jruby/xml/document.rb', line 27 def validate(dtd) dtd.validate(self) end |