xpath

package
v0.2.28 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 19, 2021 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package xpath is an XPath parser supporting the minimal subset of XPath used by Hermit. It exists so that only a single selector need be provided by package triggers, specifying the element to insert and the ability to find the parent under which to insert if the element does not exist.

nolint: govet

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Attr

type Attr struct {
	Key   string  `"@" @Ident`
	Value *string `("=" @String)?`
}

An Attr on an element in the path.

func (*Attr) String

func (a *Attr) String() string

type Component

type Component struct {
	Element string  `@(Ident | "*")`
	Attrs   []*Attr `("[" @@ ("and" @@)* "]")?`
}

A Component is an element in a path selector.

func (*Component) String

func (c *Component) String() string

type Path

type Path []*Component

Path components.

func MustParse

func MustParse(sel string) Path

MustParse parses a subset of XPath or panics.

func Parse

func Parse(sel string) (Path, error)

Parse a subset of XPath used in Hermit.

func (Path) Parent

func (p Path) Parent() Path

Parent returns the Path that will select the parent element.

func (Path) Select

func (p Path) Select(root *xmltree.Element) (selected []*xmltree.Element)

Select matches elements from a tree.

func (Path) String

func (p Path) String() string

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL