Convenience function for converting nodes matched by XPath-based
linter logic into a Lint() object to return.
xml_nodes_to_lints(
xml,
source_expression,
lint_message,
type = c("style", "warning", "error"),
column_number_xpath = range_start_xpath,
range_start_xpath = "number(./@col1)",
range_end_xpath = "number(./@col2)"
)For xml_nodes, a lint. For xml_nodesets, lints (a list of lints).
An xml_node object (to generate one Lint) or an
xml_nodeset object (to generate several Lints), e.g. as returned by
xml2::xml_find_all() or xml2::xml_find_first() or a
list of xml_node objects.
A source expression object, e.g. as
returned typically by lint(), or more generally
by get_source_expressions().
The message to be included as the message
to the Lint object. If lint_message is a character vector the same length as xml,
the i-th lint will be given the i-th message.
type of lint.
XPath expression to return the column number location of the lint.
Defaults to the start of the range matched by range_start_xpath. See details for more information.
XPath expression to return the range start location of the lint.
Defaults to the start of the expression matched by xml. See details for more information.
XPath expression to return the range end location of the lint.
Defaults to the end of the expression matched by xml. See details for more information.
The location XPaths, column_number_xpath, range_start_xpath and range_end_xpath are evaluated using
xml2::xml_find_num() and will usually be of the form "number(./relative/xpath)".
Note that the location line number cannot be changed and lints spanning multiple lines will ignore range_end_xpath.
column_number_xpath and range_start_xpath are assumed to always refer to locations on the starting line of the
xml node.