node

package
v0.0.0-...-ed74c9d Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Action

type Action interface {
	Apply(*etree.Element) bool
	Serialize() map[string]interface{}
}

type AllOf

type AllOf []Match

AllOf is a Match which checks that the element matches all of the sub-matches.

func (AllOf) Check

func (a AllOf) Check(element *etree.Element) bool

func (AllOf) Serialize

func (a AllOf) Serialize() map[string]interface{}

type AnyOf

type AnyOf []Match

AnyOf is a Match which checks that an element matches at least one of the sub-matches.

func (AnyOf) Check

func (a AnyOf) Check(element *etree.Element) bool

func (AnyOf) Serialize

func (a AnyOf) Serialize() map[string]interface{}

type AttrMatch

type AttrMatch struct {
	Attribute string
	Value     string
	Prefix    string
	Suffix    string
	Regex     *regexp.Regexp
}

AttrMatch is a match which checks an attribute against a set of constraints.

func (*AttrMatch) Check

func (a *AttrMatch) Check(element *etree.Element) bool

func (*AttrMatch) Serialize

func (a *AttrMatch) Serialize() map[string]interface{}

type InsertAttr

type InsertAttr struct {
	Attribute string
	Value     string
	If        Match
}

InsertAttr is an Action which inserts an attribute into the element.

func (*InsertAttr) Apply

func (i *InsertAttr) Apply(element *etree.Element) bool

func (*InsertAttr) Serialize

func (i *InsertAttr) Serialize() map[string]interface{}

type Match

type Match interface {
	Check(*etree.Element) bool
	Serialize() map[string]interface{}
}

Match defines an interface for matching elements.

type Node

type Node struct {
	Match    Match
	Actions  []Action
	Children []*Node
}

Node is a configuration node which may be applied to a xml etree.

func (*Node) Apply

func (n *Node) Apply(element *etree.Element) bool

Apply takes an element of an xml etree, checks for matches, and applies if matched.

func (*Node) Serialize

func (n *Node) Serialize() map[string]interface{}

type Not

type Not struct {
	Child Match
}

Not is a Match which checks that the element does not match the child match.

func (Not) Check

func (n Not) Check(element *etree.Element) bool

func (Not) Serialize

func (n Not) Serialize() map[string]interface{}

type Number

type Number struct {
	Attribute string
	Mult      float64
	Add       float64
	Min       float64
	Max       float64
	Precision int
	If        Match
}

Number represents a numeric operation.

This combines a multiply, add, and clamp operation all in one. It also contains a precision value used for formatting values back to strings.

func NewNumber

func NewNumber(attr string) *Number

NewNumber returns a Number Action which does nothing to the given attribute.

func (*Number) Apply

func (n *Number) Apply(element *etree.Element) bool

Apply updates the given element.

This will take the attribute in the element, multiply it by `Mult`, add `Add`, clamp between `Min` and `Max` inclusive, then truncate to `Precision` decimal places.

func (*Number) Serialize

func (n *Number) Serialize() map[string]interface{}

Serialize returns JSON compatible map of this Action.

type OneOf

type OneOf []Match

OneOf is a Match which checks that an element matches exactly one of the sub-matches.

func (OneOf) Check

func (o OneOf) Check(element *etree.Element) bool

func (OneOf) Serialize

func (o OneOf) Serialize() map[string]interface{}

type RemoveAttr

type RemoveAttr struct {
	Attribute string
	If        Match
}

RemoveAttr is an Action which removes an attribute from the element.

func (*RemoveAttr) Apply

func (r *RemoveAttr) Apply(element *etree.Element) bool

func (*RemoveAttr) Serialize

func (r *RemoveAttr) Serialize() map[string]interface{}

type TagMatch

type TagMatch struct {
	Value  string
	Regex  *regexp.Regexp
	Suffix string
	Prefix string
}

TagMatch is a match which checks the tag against a set of constraints.

func (*TagMatch) Check

func (t *TagMatch) Check(element *etree.Element) bool

func (*TagMatch) Serialize

func (t *TagMatch) Serialize() map[string]interface{}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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