Sha256: 0ef4749863db33c2fa7adda9270e92e31270e1fc32f0170efbf2e3764e0365d5

Contents?: true

Size: 1.24 KB

Versions: 1

Compression:

Stored size: 1.24 KB

Contents

module LibXMLJRuby
  module XML
    class Document
      class << self
        def file(filename)
          XML::Parser.file(filename).parse
        end
        
        def from_java(java_obj)
          d = new
          d.java_obj = java_obj
          d
        end
      end
      
      attr_accessor :java_obj # org.w3c.dom.Document

      def initialize(xml_version = 1.0)
        @xml_version = xml_version
        @xpath_cache = {}
      end
      
      def validate(dtd)
        dtd.validate(self)
      end
      
      def find(expr, nslist = nil)
        @xpath_cache[[expr, nslist]] ||= XML::XPath::Object.new(expr, self, nslist)
      end
      
      def find_first(expr, nslist = nil)
        find(expr, nslist).first
      end
      
      def child?
        java_obj.hasChildNodes
      end
      
      def parent?
        !!java_obj.parent_node
      end
      
      def root
        @root ||= Node.from_java(java_obj.document_element)
      end
      
      def to_s(*a)
        ###############################################################
        # TODO: Add support for to_s(:indent => false) . JKW
        ###############################################################
        self.root.to_s or super.to_s
      end
    end    
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
libxml-jruby-modified-1.0.2-jruby lib/libxml-jruby/xml/document.rb