1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
pub use MAX_NESTING_DEPTH;
pub use ;
/// A `prefix` that searches the context node and its whole subtree:
/// `"a"` becomes `descendant-or-self::a`.
pub const DESCENDANT_OR_SELF: &str = "descendant-or-self::";
/// A `prefix` that searches the whole document, wherever the expression
/// is evaluated from: `"a"` becomes `//a`.
pub const WHOLE_DOCUMENT: &str = "//";
/// Translate a CSS selector to an XPath 1.0 expression.
///
/// # Arguments
///
/// * `css` — A CSS selector string.
/// * `prefix` — An XPath path prefix prepended verbatim to each
/// selector-group branch, so it must end in something a node test can
/// follow: an axis ([`DESCENDANT_OR_SELF`]) or a step separator
/// ([`WHOLE_DOCUMENT`]). Pass `""` for a bare relative expression.
/// Nothing validates it — `"/html/body "` yields `/html/body div`,
/// which XPath reads as a division, not a path. A selector group
/// anchored on `:scope` ignores `prefix` and anchors on `self::`
/// instead.
/// * `mode` — The translator flavour: [`Mode::Generic`], [`Mode::Html`], or
/// [`Mode::Xhtml`].
///
/// # Errors
///
/// Returns an [`Error`] when the selector is syntactically invalid or uses
/// an unsupported construct.