XPathPathExpr.fromRef constructor

XPathPathExpr.fromRef(
  1. TreeReference ref
)

The relative or absolute path for ref, with plain child steps.

Port of XPathPathExpr.fromRef.

Implementation

factory XPathPathExpr.fromRef(TreeReference ref) =>
    XPathPathExpr(ref.isAbsolute ? PathStart.root : PathStart.relative, [
      for (var i = 0; i < ref.size; i++)
        ref.nameAt(i) == TreeReference.nameWildcard
            ? XPathStep.typed(XPathAxis.child, StepTest.nameWildcard)
            : XPathStep.named(
                XPathAxis.child,
                XPathQName.parse(ref.nameAt(i)),
              ),
    ]);