module Nokogiri::XML::Searchable

def xpath_query_from_css_rule(rule, ns)

def xpath_query_from_css_rule(rule, ns)
  self.class::IMPLIED_XPATH_CONTEXTS.map do |implied_xpath_context|
    visitor = Nokogiri::CSS::XPathVisitor.new(
      builtins: Nokogiri::CSS::XPathVisitor::BuiltinsConfig::OPTIMAL,
      doctype: document.xpath_doctype,
      prefix: implied_xpath_context,
      namespaces: ns,
    )
    CSS.xpath_for(rule.to_s, visitor: visitor)
  end.join(" | ")
end