lib/object_extra.rb
# Convert:
# * XPath string '/one/two/three' to '/pre:one/pre:two/pre:three'
# * XPath string 'one/two/three'  to 'pre:one/pre:two/pre:three'
# where argument or @@xpath_prefix = 'pre' or 'pre:'
#
# To be used in conjunction with xpath_prefix=().
# This is for a helper method for use with XPATH namespaces.


To be used in conjunction with xpath_prefix=().
This is for a helper method for use with XPATH namespaces.
To be used in conjunction with xpath_prefix = () . This is for a helper method for use with XPATH namespaces .
def to_s_xpath(xpath_prefix=@@xpath_prefix)
    xpath_prefix += ':' unless xpath_prefix.empty? || xpath_prefix.match(/:$/)
    self.gsub(/\//, "/#{xpath_prefix}").gsub(/^([^\/])/, "#{xpath_prefix}\\1")
  end
def to_s_xpath ( xpath_prefix = @@xpath_prefix ) xpath_prefix += ':' unless xpath_prefix . empty? || xpath_prefix . match ( / :$ / ) self . gsub ( / \/ / , "/#{xpath_prefix}" ) . gsub ( / ^([^ \/ ]) / , "#{xpath_prefix}\\1" ) end
Convert:
 XPath string '/one/two/three' to '/pre:one/pre:two/pre:three'
 XPath string 'one/two/three'  to 'pre:one/pre:two/pre:three'
where argument or @@xpath_prefix = 'pre' or 'pre:'
Convert : XPath string ' / one / two / three ' to ' / pre : one / pre : two / pre : three ' XPath string ' one / two / three ' to ' pre : one / pre : two / pre : three ' where argument or @@xpath_prefix = ' pre ' or ' pre : '
# Append colon to the prefix unless prefix is empty or prefix already has one # Add prefix after every '/' & to start of xpath unless xpath starts with '/'
xpath_prefix
<not_specific>