Module: Leptris::XML

Defined in:
lib/leptris/xml.rb,
lib/leptris/xml/ffi.rb,
lib/leptris/xml/sax.rb,
lib/leptris/xml/c14n.rb,
lib/leptris/xml/css_to_xpath.rb

Defined Under Namespace

Modules: CStringArray, CssToXPath, FFI, SAX, Searchable, Serialization Classes: Attr, CDATA, Comment, DocType, Document, DocumentFragment, Element, Error, Namespace, Node, NodeSet, ParseError, ParseOptions, ProcessingInstruction, Text, UseAfterFreeError, XPathError

Class Method Summary collapse

Class Method Details

.c14n_build_ns_pointer(inclusive_namespaces) ⇒ Object

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.

Builds a NULL-terminated const char** from a Ruby array of strings, suitable for passing to leptris_c14n_canonicalize_ex's inclusive_ns_prefixes argument. Returns [pointer, anchor] where anchor is the underlying MemoryPointer that the caller must keep alive (e.g. via local variable) for the duration of the FFI call.



12
13
14
15
16
17
18
19
20
21
# File 'lib/leptris/xml/c14n.rb', line 12

def self.c14n_build_ns_pointer(inclusive_namespaces)
  return [nil, nil] if inclusive_namespaces.nil? || inclusive_namespaces.empty?
  strs = Array(inclusive_namespaces).map(&:to_s)
  ptr_size = ::FFI.type_size(:pointer)
  buffer = ::FFI::MemoryPointer.new(:pointer, strs.size + 1)
  anchors = strs.map { |s| ::FFI::MemoryPointer.from_string(s) }
  anchors.each_with_index { |p, i| buffer.put_pointer(i * ptr_size, p) }
  buffer.put_pointer(strs.size * ptr_size, nil)
  [buffer, anchors]
end

.parse(xml_or_io, options: nil) ⇒ Object

Nokogiri-style top-level entry points (Nokogiri::XML(...) / Nokogiri::XML.parse). Delegates to Document.parse.



27
28
29
# File 'lib/leptris/xml.rb', line 27

def self.parse(xml_or_io, options: nil)
  Document.parse(xml_or_io, options: options)
end

.parse_file(path) ⇒ Object



31
32
33
# File 'lib/leptris/xml.rb', line 31

def self.parse_file(path)
  Document.parse_file(path)
end