object

package
v0.0.0-...-490b20b Latest Latest
Warning

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

Go to latest
Published: Apr 9, 2021 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Array

type Array struct {
	Items []Item
}

Array is an item that is represents array data-type

func (*Array) Inspect

func (a *Array) Inspect() string

Inspect ::= [...]

func (*Array) Type

func (a *Array) Type() Type

Type ::= ArrayType

type AttrNode

type AttrNode struct {
	// contains filtered or unexported fields
}

AttrNode ::= AttributeNode Attribute node is not exist in the golang.org/x/net/html package so the struct field is different from the BaseNode. AttrNode is basically, a child of ElementNode.

func (*AttrNode) Attr

func (an *AttrNode) Attr() html.Attribute

Attr returns attr field

func (*AttrNode) FirstChild

func (an *AttrNode) FirstChild() Node

FirstChild is not exist in AttrNode

func (*AttrNode) Inspect

func (an *AttrNode) Inspect() string

Inspect returns a value of the attr field

func (*AttrNode) Key

func (an *AttrNode) Key() string

Key returns a key of the attr field

func (*AttrNode) LastChild

func (an *AttrNode) LastChild() Node

LastChild is not exist in AttrNode

func (*AttrNode) NextSibling

func (an *AttrNode) NextSibling() Node

NextSibling returns next sibling of the current one if exist

func (*AttrNode) Parent

func (an *AttrNode) Parent() Node

Parent returns parent node of the current one if exist

func (*AttrNode) PrevSibling

func (an *AttrNode) PrevSibling() Node

PrevSibling returns previous sibling of the current one if exist

func (*AttrNode) Self

func (an *AttrNode) Self() *html.Node

Self returns customized *html.Node which represents Attribute node

func (*AttrNode) SetAttr

func (an *AttrNode) SetAttr(attr html.Attribute)

SetAttr is setter for the attr field

func (*AttrNode) SetTree

func (an *AttrNode) SetTree(p *html.Node)

SetTree is setter for the parent field

func (*AttrNode) Text

func (an *AttrNode) Text() string

func (*AttrNode) Tree

func (an *AttrNode) Tree() *html.Node

Tree is getter for the parent field

func (*AttrNode) Type

func (an *AttrNode) Type() Type

Type ::= AttributeNodeType

type BaseNode

type BaseNode struct {
	// contains filtered or unexported fields
}

BaseNode ::= ElementNode | TextNode | DocumentNode | CommentNode | DoctypeNode BaseNode just wraps *html.Node

func (*BaseNode) Attr

func (bn *BaseNode) Attr() []Node

Attr returns Attr field of element node with wrap it to AttrNode

func (*BaseNode) FirstChild

func (bn *BaseNode) FirstChild() Node

FirstChild returns first child node of the current one if exist

func (*BaseNode) Inspect

func (bn *BaseNode) Inspect() string

Inspect ::= *html.Node.Data

func (*BaseNode) LastChild

func (bn *BaseNode) LastChild() Node

LastChild returns last child node of the current one if exist

func (*BaseNode) NextSibling

func (bn *BaseNode) NextSibling() Node

NextSibling returns next sibling node of the current one if exist

func (*BaseNode) Parent

func (bn *BaseNode) Parent() Node

Parent returns parent node of the current one if exist

func (*BaseNode) PrevSibling

func (bn *BaseNode) PrevSibling() Node

PrevSibling returns previous sibling node of the current one if exist

func (*BaseNode) Self

func (bn *BaseNode) Self() *html.Node

Self is getter for the BaseNode

func (*BaseNode) SetTree

func (bn *BaseNode) SetTree(tree *html.Node)

SetTree is setter for the BaseNode

func (*BaseNode) Text

func (bn *BaseNode) Text() string

Text returns *html.Node.Data

func (*BaseNode) Tree

func (bn *BaseNode) Tree() *html.Node

Tree returns *html.Node. BaseNode is just a wrapper type for the *html.Node

func (*BaseNode) Type

func (bn *BaseNode) Type() Type

Type ::= ElementNodeType | TextNodeType | DocumentNodeType | CommentNodeType | DoctypeNodeType | RawNodeType

type Boolean

type Boolean struct {
	// contains filtered or unexported fields
}

Boolean is an item that is represents bool data-type

func (*Boolean) HashKey

func (b *Boolean) HashKey() HashKey

HashKey used as a map key

func (*Boolean) Inspect

func (b *Boolean) Inspect() string

Inspect ::= %t

func (*Boolean) SetValue

func (b *Boolean) SetValue(v bool)

SetValue is setter for the Boolean

func (*Boolean) Type

func (b *Boolean) Type() Type

Type ::= BooleanType

func (*Boolean) Value

func (b *Boolean) Value() bool

Value is getter for the Boolean

type Context

type Context struct {
	Doc   Node
	CNode []Node
	CItem Item
	Focus
	Static
	// contains filtered or unexported fields
}

Context contains items that is used in Eval or built-in functions store field stores Varref as a key, Item as as value In example expression, let $a := 1 return $a, 'a' is a key and 1 is a value outer is a context to make inner scope of function. In example expression, let $a := 1 return function($a) {$a} returned function makes new context to keep the varref $a

func NewContext

func NewContext() *Context

NewContext creates a new context

func NewEnclosedContext

func NewEnclosedContext(outer *Context) *Context

NewEnclosedContext creates a new context and stores the current context in the outer field

func (*Context) Get

func (c *Context) Get(name string) (Item, bool)

Get retrieve items from the store field or the outer field.

func (*Context) Set

func (c *Context) Set(name string, val Item) Item

Set save item in the current context

type Decimal

type Decimal struct {
	// contains filtered or unexported fields
}

Decimal is an item that is represents float64 data-type number token that is not contains `e` or `E` is evaluated to Decimal

func (*Decimal) HashKey

func (d *Decimal) HashKey() HashKey

HashKey used as a map key

func (*Decimal) Inspect

func (d *Decimal) Inspect() string

Inspect ::= %f

func (*Decimal) SetValue

func (d *Decimal) SetValue(v float64)

SetValue is setter for the Decimal

func (*Decimal) Type

func (d *Decimal) Type() Type

Type ::= DecimalType

func (*Decimal) Value

func (d *Decimal) Value() float64

Value is getter for the Decimal

type Double

type Double struct {
	// contains filtered or unexported fields
}

Double is an item that is represents float64 data-type number token that contains `e` or `E` is evaluated to Double

func (*Double) HashKey

func (d *Double) HashKey() HashKey

HashKey used as a map key

func (*Double) Inspect

func (d *Double) Inspect() string

Inspect ::= %e

func (*Double) SetValue

func (d *Double) SetValue(v float64)

SetValue is setter for the Double

func (*Double) Type

func (d *Double) Type() Type

Type ::= DoubleType

func (*Double) Value

func (d *Double) Value() float64

Value is getter for the Double

type Error

type Error struct {
	Message string
}

Error is an item that is represents error when doing evaluation

func (*Error) Inspect

func (e *Error) Inspect() string

Inspect ::= "Error: " + e.Message

func (*Error) Type

func (e *Error) Type() Type

Type ::= ErrorType

type Ev

type Ev func(expr ast.ExprSingle, ctx *Context) Item

Ev represents Eval function

type Focus

type Focus struct {
	CSize int
	CPos  int
	CAxis string
}

Focus contains context size, context position, context axis CSize is used in bif - fn:last() CPos is used in predicate expressions CAxis is used to evaluate (relative)path expressions

type Func

type Func func(ctx *Context, args ...Item) Item

Func represents function type

type FuncInline

type FuncInline struct {
	PL   *ast.ParamList
	Body *ast.EnclosedExpr
	Fn   Ev
	*Context
}

FuncInline ::= function() {}

func (*FuncInline) Inspect

func (fi *FuncInline) Inspect() string

Inspect ::= function

func (*FuncInline) Type

func (fi *FuncInline) Type() Type

Type ::= FuncType

type FuncNamed

type FuncNamed struct {
	Name ast.EQName
	Num  int
	*Context
	*Func
}

FuncNamed ::= ns:bif#n

func (*FuncNamed) Inspect

func (fn *FuncNamed) Inspect() string

func (*FuncNamed) Type

func (fn *FuncNamed) Type() Type

type FuncPartial

type FuncPartial struct {
	Name ast.EQName
	Args []Item
	PCnt int
	*Context
	*Func
}

FuncPartial ::= ns:bif(?,...)

func (*FuncPartial) Inspect

func (fp *FuncPartial) Inspect() string

func (*FuncPartial) Type

func (fp *FuncPartial) Type() Type

Type ::= FuncType

type HashKey

type HashKey struct {
	Type
	Value uint64
}

HashKey is used as a Map key

type Hasher

type Hasher interface {
	HashKey() HashKey
}

Hasher implemented in atomic types: integer, decimal, double, boolean, string So, atomic types are used as a Map key

type Integer

type Integer struct {
	// contains filtered or unexported fields
}

Integer is an item that is represents int data-type

func (*Integer) HashKey

func (i *Integer) HashKey() HashKey

HashKey used as a map key

func (*Integer) Inspect

func (i *Integer) Inspect() string

Inspect ::= %d

func (*Integer) SetValue

func (i *Integer) SetValue(v int)

SetValue is setter for the Integer

func (*Integer) Type

func (i *Integer) Type() Type

Type ::= IntegerType

func (*Integer) Value

func (i *Integer) Value() int

Value is getter for the Integer

type Item

type Item interface {
	Type() Type
	Inspect() string
}

Item ::= node | function(*) | xs:anyAtomicType

type Map

type Map struct {
	Pairs map[HashKey]Pair
}

Map is an item that is represents map data-type

func (*Map) Inspect

func (m *Map) Inspect() string

Inspect ::= map{...}

func (*Map) Type

func (m *Map) Type() Type

Type ::= MapType

type Node

type Node interface {
	Item
	Tree() *html.Node
	SetTree(t *html.Node)
	Self() *html.Node
	Parent() Node
	FirstChild() Node
	LastChild() Node
	PrevSibling() Node
	NextSibling() Node
	Text() string
}

Node ::= document, element, attribute, comment, namespace, processing-instruction, text

type Pair

type Pair struct {
	Key   Item
	Value Item
}

Pair contains key, value pair

type Placeholder

type Placeholder struct{}

Placeholder is an item that is represents ?(question token) when doing evaluation

func (*Placeholder) Inspect

func (p *Placeholder) Inspect() string

Inspect ::= ?

func (*Placeholder) Type

func (p *Placeholder) Type() Type

Type ::= PholderType

type Sequence

type Sequence struct {
	Items []Item
}

Sequence is an ordered collection of zero or more items.

func (*Sequence) Inspect

func (s *Sequence) Inspect() string

Inspect ::= (...)

func (*Sequence) Type

func (s *Sequence) Type() Type

Type ::= SequenceType

type Static

type Static struct {
	BaseURI string
}

Static contains information that is available during static analysis of the expression, prior to its evaluation

type String

type String struct {
	// contains filtered or unexported fields
}

String is an item that is represents string data-type

func (*String) HashKey

func (s *String) HashKey() HashKey

HashKey used as a map key

func (*String) Inspect

func (s *String) Inspect() string

Inspect ::= string

func (*String) SetValue

func (s *String) SetValue(v string)

SetValue is setter for the String

func (*String) Type

func (s *String) Type() Type

Type ::= StringType

func (*String) Value

func (s *String) Value() string

Value is getter for the String

type Type

type Type string

Type represents Item Type

const (
	NilType      Type = "nil"
	ErrorType    Type = "error"
	PholderType  Type = "?"
	VarrefType   Type = "$"
	SequenceType Type = "sequence"

	// function
	MapType   Type = "map"
	ArrayType Type = "array"
	FuncType  Type = "function"

	// node
	ErrorNodeType     Type = "0"
	TextNodeType      Type = "1"
	DocumentNodeType  Type = "2"
	ElementNodeType   Type = "3"
	CommentNodeType   Type = "4"
	DoctypeNodeType   Type = "5"
	RawNodeType       Type = "6"
	AttributeNodeType Type = "7"

	// atomic
	DoubleType  Type = "xs:double"
	DecimalType Type = "xs:decimal"
	IntegerType Type = "xs:integer"
	StringType  Type = "xs:string"
	BooleanType Type = "xs:boolean"
)

Item Types

type Varref

type Varref struct {
	Name ast.EQName
}

Varref is an item that is represents $var when doing evaluation

func (*Varref) Inspect

func (v *Varref) Inspect() string

Inspect ::= EQName.Value()

func (*Varref) Type

func (v *Varref) Type() Type

Type ::= VarrefType

Jump to

Keyboard shortcuts

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