Module: OM::XML::Document

Included in:
Samples::ModsArticle
Defined in:
lib/om/xml/document.rb

Defined Under Namespace

Modules: ClassMethods

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#ox_namespacesObject

Returns a hash combining the current documents namespaces (provided by nokogiri) and any namespaces that have been set up by your Terminology. Most importantly, this matches the ‘oxns’ namespace to the namespace you provided in your Terminology’s root term config



29
30
31
# File 'lib/om/xml/document.rb', line 29

def ox_namespaces
  @ox_namespaces
end

Class Method Details

.included(klass) ⇒ Object



31
32
33
34
35
36
# File 'lib/om/xml/document.rb', line 31

def self.included(klass)
  klass.extend(ClassMethods)

  klass.send(:include, OM::XML::Container)
  klass.send(:include, OM::XML::TermValueOperators)
end

Instance Method Details

#find_by_terms(*term_pointer) ⇒ Object

term_pointer Variable length array of values in format [:accessor_name, :accessor_name …] or [:accessor_name=>index, :accessor_name …] example: => 1, :first_name example: [:person, 1, :first_name] Currently, indexes must be integers.



53
54
55
56
57
58
59
60
# File 'lib/om/xml/document.rb', line 53

def find_by_terms(*term_pointer)
  xpath = self.class.terminology.xpath_with_indexes(*term_pointer)   
  if xpath.nil?
    return nil
  else
    return ng_xml.xpath(xpath, ox_namespaces) 
  end   
end

#find_by_terms_and_value(*term_pointer) ⇒ Object

Applies the property’s corresponding xpath query, returning the result Nokogiri::XML::NodeSet



39
40
41
42
43
44
45
46
# File 'lib/om/xml/document.rb', line 39

def find_by_terms_and_value(*term_pointer)
  xpath = self.class.terminology.xpath_for(*term_pointer)    
  if xpath.nil?
    return nil
  else
    return ng_xml.xpath(xpath, ox_namespaces) 
  end
end