Module: Handsoap::XmlQueryFront::XmlElement
- Included in:
 - LibXMLDriver, NokogiriDriver, REXMLDriver
 
- Defined in:
 - lib/handsoap/xml_query_front.rb
 
Overview
Wraps the underlying (native) xml driver, and provides a uniform interface.
Instance Method Summary collapse
- 
  
    
      #/(expression)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
alias of
xpath. - 
  
    
      #[](attribute_name)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the attribute value of the underlying element.
 - 
  
    
      #add_namespace(prefix, uri)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Registers a prefix to refer to a namespace.
 - 
  
    
      #assert_prefixes!(expression, ns)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Checks that an xpath-query doesn’t refer to any undefined prefixes in
ns. - 
  
    
      #children  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns a
NodeSelection. - #initialize(element, namespaces = {}) ⇒ Object
 - 
  
    
      #native_element  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the underlying native element.
 - 
  
    
      #node_name  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the node name of the current element.
 - 
  
    
      #node_namespace  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the node namespace uri of the current element if any,
nilotherwise. - 
  
    
      #to_boolean  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the value of the element as an boolean.
 - 
  
    
      #to_date  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the value of the element as a ruby Time object.
 - 
  
    
      #to_f  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the value of the element as a float.
 - 
  
    
      #to_i  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the value of the element as an integer.
 - 
  
    
      #to_raw  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the outer XML for this element, preserving the original formatting.
 - 
  
    
      #to_s  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the inner text content of this element, or the value (if it’s an attr or textnode).
 - 
  
    
      #to_xml  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Returns the outer XML for this element.
 - 
  
    
      #xpath(expression, ns = nil)  ⇒ Object 
    
    
  
  
  
  
  
  
  
  
  
    
Queries the document with XPath, relative to the current element.
 
Instance Method Details
#/(expression) ⇒ Object
alias of xpath
      206 207 208  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 206 def /(expression) self.xpath(expression) end  | 
  
#[](attribute_name) ⇒ Object
Returns the attribute value of the underlying element.
Shortcut for:
(node/"@attribute_name").to_s
  
      214 215 216  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 214 def [](attribute_name) raise NotImplementedError.new end  | 
  
#add_namespace(prefix, uri) ⇒ Object
Registers a prefix to refer to a namespace.
You can either register a nemspace with this function or pass it explicitly to the xpath method.
      121 122 123  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 121 def add_namespace(prefix, uri) @namespaces[prefix] = uri end  | 
  
#assert_prefixes!(expression, ns) ⇒ Object
Checks that an xpath-query doesn’t refer to any undefined prefixes in ns
      125 126 127 128 129  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 125 def assert_prefixes!(expression, ns) expression.scan(/([a-zA-Z_][a-zA-Z0-9_.-]*):[^:]+/).map{|m| m[0] }.each do |prefix| raise "Undefined prefix '#{prefix}' in #{ns.inspect}" if ns[prefix].nil? end end  | 
  
#children ⇒ Object
Returns a NodeSelection
      194 195 196  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 194 def children raise NotImplementedError.new end  | 
  
#initialize(element, namespaces = {}) ⇒ Object
      114 115 116 117  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 114 def initialize(element, namespaces = {}) @element = element @namespaces = namespaces end  | 
  
#native_element ⇒ Object
Returns the underlying native element.
You shouldn’t need to use this, since doing so would void portability.
      171 172 173  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 171 def native_element @element end  | 
  
#node_name ⇒ Object
Returns the node name of the current element.
      175 176 177  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 175 def node_name raise NotImplementedError.new end  | 
  
#node_namespace ⇒ Object
Returns the node namespace uri of the current element if any, nil otherwise. Result returned for attribute nodes varies for different drivers, currently.
      180 181 182  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 180 def node_namespace raise NotImplementedError.new end  | 
  
#to_boolean ⇒ Object
Returns the value of the element as an boolean.
See to_s
      149 150 151 152 153  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 149 def to_boolean t = self.to_s return if t.nil? t.downcase == 'true' end  | 
  
#to_date ⇒ Object
Returns the value of the element as a ruby Time object.
See to_s
      157 158 159 160 161  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 157 def to_date t = self.to_s return if t.nil? Time.iso8601(t) end  | 
  
#to_f ⇒ Object
Returns the value of the element as a float.
See to_s
      141 142 143 144 145  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 141 def to_f t = self.to_s return if t.nil? t.to_f end  | 
  
#to_i ⇒ Object
Returns the value of the element as an integer.
See to_s
      133 134 135 136 137  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 133 def to_i t = self.to_s return if t.nil? t.to_i end  | 
  
#to_raw ⇒ Object
Returns the outer XML for this element, preserving the original formatting.
      202 203 204  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 202 def to_raw raise NotImplementedError.new end  | 
  
#to_s ⇒ Object
Returns the inner text content of this element, or the value (if it’s an attr or textnode).
The output is a UTF-8 encoded string, without xml-entities.
      165 166 167  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 165 def to_s raise NotImplementedError.new end  | 
  
#to_xml ⇒ Object
Returns the outer XML for this element.
      198 199 200  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 198 def to_xml raise NotImplementedError.new end  | 
  
#xpath(expression, ns = nil) ⇒ Object
Queries the document with XPath, relative to the current element.
ns Should be a Hash of prefix => namespace
Returns a NodeSelection
See add_namespace
      190 191 192  | 
    
      # File 'lib/handsoap/xml_query_front.rb', line 190 def xpath(expression, ns = nil) raise NotImplementedError.new end  |