Skip to content

Commit

Permalink
Improve comments for XPath context.
Browse files Browse the repository at this point in the history
  • Loading branch information
renggli committed Dec 2, 2023
1 parent 83d07b4 commit bc00451
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions lib/src/xpath/evaluation/context.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import '../../xml/nodes/node.dart';
import 'functions.dart';
import 'values.dart';

/// Runtime execution context to evaluate XPath expressions.
class XPathContext {
XPathContext(
this.node, {
Expand All @@ -11,12 +12,16 @@ class XPathContext {
this.functions = const {},
});

/// Mutable context node.
XmlNode node;

/// Mutable context position.
int position = 1;

/// Mutable context size.
int last = 1;

/// The current node as an [XPathValue].
XPathValue get value => XPathNodeSet([node]);

/// Looks up an XPath variable with the given [name].
Expand All @@ -26,10 +31,13 @@ class XPathContext {
XPathFunction? getFunction(String name) =>
functions[name] ?? standardFunctions[name];

/// User-defined variables.
final Map<String, XPathValue> variables;

/// User-defined functions.
final Map<String, XPathFunction> functions;

/// Creates a copy of the current context.
XPathContext copy() => XPathContext(
node,
position: position,
Expand Down

0 comments on commit bc00451

Please sign in to comment.