Module: Qti::XPathHelpers

Included in:
Models::Manifest, Models::Resource, V2::Models::AssessmentTest
Defined in:
lib/qti/xpath_helpers.rb

Instance Method Summary collapse

Instance Method Details

#rtype_predicate(ver, rsc_type) ⇒ Object



11
12
13
14
15
16
17
18
# File 'lib/qti/xpath_helpers.rb', line 11

def rtype_predicate(ver, rsc_type)
  # XPath 2.0 supports ends-with, which is what substring is doing here.
  # It also support regex matching with matches.
  # We only have XPath 1.0 available.
  cc_match = "starts-with(@type, '#{ver}') and " + xpath_endswith('@type', rsc_type)
  qti_match = "@type='#{ver}'"
  "#{qti_match} or (#{cc_match})"
end

#xpath_endswith(tag, tail) ⇒ Object



7
8
9
# File 'lib/qti/xpath_helpers.rb', line 7

def xpath_endswith(tag, tail)
  "substring(#{tag}, string-length(#{tag}) - string-length('#{tail}') + 1) = '#{tail}'"
end

#xpath_resource(type = '') ⇒ Object



3
4
5
# File 'lib/qti/xpath_helpers.rb', line 3

def xpath_resource(type = '')
  "//xmlns:resources/xmlns:resource#{type}"
end