class Nokogiri::CSS::XPathVisitor
When translating CSS
selectors to XPath queries with Nokogiri::CSS.xpath_for
, the XPathVisitor
class allows for changing some of the behaviors related to builtin xpath functions and quirks of HTML5
.
Attributes
The visitor configuration set via the builtins:
keyword argument to XPathVisitor.new
.
The visitor configuration set via the doctype:
keyword argument to XPathVisitor.new
.
The visitor configuration set via the namespaces:
keyword argument to XPathVisitor.new
.
The visitor configuration set via the prefix:
keyword argument to XPathVisitor.new
.
Public Class Methods
- Parameters
-
builtins:
(BuiltinsConfig
) Determine when to use Nokogiri’s built-in xpath functions for performance improvements. -
doctype:
(DoctypeConfig
) Make document-type-specific accommodations forCSS
queries.
- Returns
# File lib/nokogiri/css/xpath_visitor.rb, line 69 def initialize( builtins: BuiltinsConfig::NEVER, doctype: DoctypeConfig::XML, prefix: Nokogiri::XML::XPath::GLOBAL_SEARCH_PREFIX, namespaces: nil ) unless BuiltinsConfig::VALUES.include?(builtins) raise(ArgumentError, "Invalid values #{builtins.inspect} for builtins: keyword parameter") end unless DoctypeConfig::VALUES.include?(doctype) raise(ArgumentError, "Invalid values #{doctype.inspect} for doctype: keyword parameter") end @builtins = builtins @doctype = doctype @prefix = prefix @namespaces = namespaces end
Public Instance Methods
- Returns
-
a Hash representing the configuration of the
XPathVisitor
, suitable for use as part of theCSS
cache key.
# File lib/nokogiri/css/xpath_visitor.rb, line 93 def config { builtins: @builtins, doctype: @doctype, prefix: @prefix, namespaces: @namespaces } end