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
- #to_s(*a) ⇒ Object
- #validate(dtd) ⇒ Object
Constructor Details
#initialize(xml_version = 1.0) ⇒ Document
Returns a new instance of Document.
18 19 20 21 |
# File 'lib/libxml-jruby/xml/document.rb', line 18 def initialize(xml_version = 1.0) @xml_version = xml_version @xpath_cache = {} end |
Instance Attribute Details
#java_obj ⇒ Object
org.w3c.dom.Document
16 17 18 |
# File 'lib/libxml-jruby/xml/document.rb', line 16 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) XML::Parser.file(filename).parse end |
.from_java(java_obj) ⇒ Object
9 10 11 12 13 |
# File 'lib/libxml-jruby/xml/document.rb', line 9 def from_java(java_obj) d = new d.java_obj = java_obj d end |
Instance Method Details
#child? ⇒ Boolean
35 36 37 |
# File 'lib/libxml-jruby/xml/document.rb', line 35 def child? java_obj.hasChildNodes end |
#find(expr, nslist = nil) ⇒ Object
27 28 29 |
# File 'lib/libxml-jruby/xml/document.rb', line 27 def find(expr, nslist = nil) @xpath_cache[[expr, nslist]] ||= XML::XPath::Object.new(expr, self, nslist) end |
#find_first(expr, nslist = nil) ⇒ Object
31 32 33 |
# File 'lib/libxml-jruby/xml/document.rb', line 31 def find_first(expr, nslist = nil) find(expr, nslist).first end |
#parent? ⇒ Boolean
39 40 41 |
# File 'lib/libxml-jruby/xml/document.rb', line 39 def parent? !!java_obj.parent_node end |
#root ⇒ Object
43 44 45 |
# File 'lib/libxml-jruby/xml/document.rb', line 43 def root @root ||= Node.from_java(java_obj.document_element) end |
#to_s(*a) ⇒ Object
47 48 49 50 51 52 |
# File 'lib/libxml-jruby/xml/document.rb', line 47 def to_s(*a) ############################################################### # TODO: Add support for to_s(:indent => false) . JKW ############################################################### self.root.to_s or super.to_s end |
#validate(dtd) ⇒ Object
23 24 25 |
# File 'lib/libxml-jruby/xml/document.rb', line 23 def validate(dtd) dtd.validate(self) end |