Sha256: 056b43400d6f191e7f7c16f3d8ed05ea4a017a74bb80b8dc0158ac31332f5e19

Contents?: true

Size: 944 Bytes

Versions: 19

Compression:

Stored size: 944 Bytes

Contents

module Nokogiri
  module Decorators
    module Hpricot
      ####
      # This mixin does custom adjustments to deal with _whyML
      module XPathVisitor
        ###
        # Visit attribute condition nodes with +node+
        def visit_attribute_condition node
          unless (node.value.first.type == :FUNCTION) or (node.value.first.value.first =~ /^@/)
            node.value.first.value[0] = "child::" +
              node.value.first.value[0]
          end
          super(node).gsub(/child::text\(\)/, 'normalize-space(child::text())')
        end

        #  take a path like '//t:sam' and convert to xpath "*[name()='t:sam']"
        def self.xpath_namespace_helper rule
          rule.split(/\//).collect do |tag|
            if match = tag.match(/^(\w+:\w+)(.*)/)
              "*[name()='#{match[1]}']#{match[2]}"
            else
              tag
            end
          end.join("/")
        end
      end
    end
  end
end

Version data entries

19 entries across 19 versions & 2 rubygems

Version Path
akamai_bookmarklet-0.1.2 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/xpath_visitor.rb
akamai_bookmarklet-0.1.1 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/xpath_visitor.rb
akamai_bookmarklet-0.1.0 vendor/gems/ruby/1.8/gems/nokogiri-1.3.3/lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.3-x86-mswin32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.3-x86-mingw32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.3-java lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.2-x86-mswin32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.2-x86-mingw32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.2-java lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.0-x86-mingw32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.2 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.3 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.0-java lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.1-java lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.0 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.0-x86-mswin32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.1-x86-mingw32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.1-x86-mswin32 lib/nokogiri/decorators/hpricot/xpath_visitor.rb
nokogiri-1.3.1 lib/nokogiri/decorators/hpricot/xpath_visitor.rb