exec

package
v0.9.16 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetCursorString added in v0.9.16

func GetCursorString(c store.Cursor) string

func Unmarshal added in v0.9.10

func Unmarshal(result Result, value any, settings ...ContextApply) error

Unmarshal maps a XPath result to a struct or slice. When unmarshaling a slice, the result must be a NodeSet. When unmarshaling a struct, the result must be a NodeSet with one result. To unmarshal a value to a struct field, give it a "xsel" tag name, and a XPath expression for its value (e.g. `xsel:"//my-struct[@my-id = 'my-value']"`).

For struct fields, Unmarshal can set fields that are ints and uints, bools, strings, slices, and nested structs.

For slice elements, Unmarshal can set ints and uints, bools, strings, and structs. It cannot Unmarshal multidimensional slices.

Arrays, maps, and channels are not supported.

Types

type Bool

type Bool bool

func (Bool) Bool

func (b Bool) Bool() bool

func (Bool) Number

func (b Bool) Number() float64

func (Bool) String

func (b Bool) String() string

type Context

type Context interface {
	Result() Result
	ContextPosition() int
}

type ContextApply

type ContextApply func(c *ContextSettings)

type ContextSettings

type ContextSettings struct {
	NamespaceDecls  map[string]string
	FunctionLibrary map[XmlName]Function
	Variables       map[XmlName]Result
}

ContextSettings allows you to add namespace mappings, create new functions, and add variable bindings to your XPath query.

type Function

type Function func(context Context, args ...Result) (Result, error)

type NodeSet

type NodeSet []store.Cursor

func (NodeSet) Bool

func (n NodeSet) Bool() bool

func (NodeSet) Number

func (n NodeSet) Number() float64

func (NodeSet) String

func (n NodeSet) String() string

type Number

type Number float64

func (Number) Bool

func (n Number) Bool() bool

func (Number) Number

func (n Number) Number() float64

func (Number) String

func (n Number) String() string

type Result

type Result interface {
	String() string
	Number() float64
	Bool() bool
}

func Exec

func Exec(cursor store.Cursor, expr *grammar.Grammar, settings ...ContextApply) (Result, error)

Executes an XPath query against the given Cursor and returns the result.

type String

type String string

func (String) Bool

func (n String) Bool() bool

func (String) Number

func (n String) Number() float64

func (String) String

func (n String) String() string

type XmlName

type XmlName struct {
	Space string
	Local string
}

func GetQName added in v0.9.1

func GetQName(input string, namespaces map[string]string) (XmlName, error)

func (XmlName) String added in v0.9.3

func (n XmlName) String() string

Jump to

Keyboard shortcuts

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