Skip to main content

parse_pattern

Function parse_pattern 

Source
pub fn parse_pattern(src: &str, namespaces: &dyn Namespaces) -> Result<Pattern>
Expand description

Parses an XSLT match pattern.

XSLT 3.0 parenthesized patterns are read as Saxon-HE 12.10 reads them, normalised:

  • (P) without predicate, as the whole of an alternative, is P: its alternatives become alternatives of the pattern ((a | b) is a | b, two template rules with their own default priorities when the template has no priority);
  • a path ending with a parenthesized step without predicate is distributed over the alternatives of that step: r/(a | b/c) is r/a | r/b/c (Saxon makes it a union pattern, split like one);
  • kept as a PathStep::Parenthesized: the first step of a path, with or without predicates ((a | b)[p], (a/b | c)[p]/d), and a step between two others without predicate whose alternatives are single steps ((a | b)/(c | d)/e).

Refused as unsupported: a predicate on a parenthesized step after the first (Saxon refuses most of them, XTSE0340), a parenthesized step nested inside another one that is kept, and, inside a parenthesized step that is not the first, or after / or //, alternatives other than single relative steps.

ยงErrors

A syntax error, a construct outside the supported subset, or an undeclared prefix.