XPathElem
XPath 3.1 AST. The root of the type hierarchy is XPathElem. It offers the ElemApi query API.
XPath 3.1 AST. The root of the type hierarchy is XPathElem. It offers the ElemApi query API.
The requirements on this AST are as follows:
-
It must represent the syntax tree of a successfully parsed XPath expression
-
It is not annotated with more semantic information, like type information that is not included in the XPath expression
-
It does not know anything about the context in which it runs, like bound namespaces etc.
-
It is rich enough to be able to serialize the AST back to XPath, knowing exactly where to place parentheses, braces, etc.
-
It is rich enough to contain operator precedence in the AST itself
-
It must be readable in that object composition trees are not unnecessarily deep and therefore hard to comprehend
-
Serialization of the AST to XPath may lead to differences in whitespace (and operator aliases), but other than that the result must be the same
-
The AST class hierarchy does not have to use the exact same names as the XPath grammar
-
Instances of the AST classes are easy to create in an ad-hoc manner, so they contain no parsing state
-
The AST classes are case classes, with value equality and good support for pattern matching
It would be natural for the AST types to have IS-A relationships modeled as type inheritance, and HAS-A relationships modeled as composition. Where feasible, this approach has been followed. Consequently, sealed trait inheritance has been used a lot (IS-A instead of HAS-A), and unnecessarily deep object trees are prevented in this way.
Having such an AST of a successfully parsed XPath expression, it must be easy to reliably find used namespace prefixes, for example.
TODO Improve several class names.
- Authors
Chris de Vreeze
Value members
Abstract methods
Inherited methods
- Inherited from
- ElemLike