Class: Saxon::XML::Document
- Inherits:
-
Object
- Object
- Saxon::XML::Document
- Defined in:
- lib/saxon/xml.rb
Overview
Parse an XML File or String into a Document object
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(xdm_document) ⇒ Document
constructor
private
A new instance of Document.
-
#processor ⇒ Saxon::Processor
Return the processor used to create this document.
-
#to_java ⇒ net.sf.saxon.s9api.XdmNode
Return the underlying Saxon document object.
-
#to_s ⇒ String
Return a simple serialisation of the document.
-
#xpath(expr) ⇒ net.sf.saxon.s9api.XdmValue
Return the value, node, or nodes selected.
Constructor Details
#initialize(xdm_document) ⇒ Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
Returns a new instance of Document.
38 39 40 |
# File 'lib/saxon/xml.rb', line 38 def initialize(xdm_document) @xdm_document = xdm_document end |
Class Method Details
.parse(processor, string_or_io, opts = {}) ⇒ Saxon::XML::Document
This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.
23 24 25 26 27 28 |
# File 'lib/saxon/xml.rb', line 23 def self.parse(processor, string_or_io, opts = {}) builder = processor.to_java.newDocumentBuilder() source = SourceHelper.to_stream_source(string_or_io, opts) xdm_document = builder.build(source) new(xdm_document) end |
Instance Method Details
#processor ⇒ Saxon::Processor
Return the processor used to create this document
55 56 57 |
# File 'lib/saxon/xml.rb', line 55 def processor Saxon::Processor.new(@xdm_document.processor) end |
#to_java ⇒ net.sf.saxon.s9api.XdmNode
Return the underlying Saxon document object
44 45 46 |
# File 'lib/saxon/xml.rb', line 44 def to_java @xdm_document end |
#to_s ⇒ String
Return a simple serialisation of the document
49 50 51 |
# File 'lib/saxon/xml.rb', line 49 def to_s @xdm_document.to_s end |
#xpath(expr) ⇒ net.sf.saxon.s9api.XdmValue
Return the value, node, or nodes selected
33 34 35 |
# File 'lib/saxon/xml.rb', line 33 def xpath(expr) processor.to_java.new_xpath_compiler.evaluate(expr, @xdm_document) end |