Documentation
¶
Index ¶
- Variables
- func BooleanValue(s Sequence) (bool, error)
- func ItemStringvalue(itm Item) string
- func NumberValue(s Sequence) (float64, error)
- func RegisterFunction(f *Function)
- func StringValue(s Sequence) (string, error)
- func ToXSInteger(itm Item) (int, error)
- type Context
- func (ctx *Context) Attributes(tf testfuncAttributes) (Sequence, error)
- func (ctx *Context) Current(tf testfuncChildren) (Sequence, error)
- func (ctx *Context) CurrentItem() Item
- func (ctx *Context) Document() goxml.XMLNode
- func (ctx *Context) Filter(filter EvalFunc) (Sequence, error)
- func (ctx *Context) GetContextSequence() Sequence
- func (ctx *Context) ResetFrom(src *Context)
- func (ctx *Context) Root() (Sequence, error)
- func (ctx *Context) SetContextSequence(seq Sequence) Sequence
- func (ctx *Context) SetCurrentItem(item Item)
- func (ctx *Context) SetSize(n int)
- func (ctx *Context) Size() int
- type EvalFunc
- type Function
- type Item
- type MapEntry
- type Parser
- type Sequence
- type Tokenlist
- type XPathArray
- type XPathMap
- type XSDate
- type XSDateTime
- type XSDuration
- type XSQName
- type XSTime
Constants ¶
This section is empty.
Variables ¶
var ( // ErrConversion is returned in case of an unsuccessful cast. ErrConversion = fmt.Errorf("conversion failed") )
var ErrSequence = fmt.Errorf("a sequence with more than one item is not allowed here")
ErrSequence is raised when a sequence of items is not allowed as an argument.
Functions ¶
func BooleanValue ¶
BooleanValue returns the effective boolean value of the sequence. XPath 2.0 §2.4.3: if the first item is a node, returns true; a single atomic value is converted to boolean; otherwise FORG0006.
func ItemStringvalue ¶ added in v1.0.6
ItemStringvalue returns the string value of an individual item.
func NumberValue ¶
NumberValue returns the sequence converted to a float.
func RegisterFunction ¶
func RegisterFunction(f *Function)
RegisterFunction registers an XPath function
func StringValue ¶
StringValue returns the string value of the sequence by concatenating the string values of each item.
func ToXSInteger ¶
ToXSInteger converts the item to an xs:integer.
Types ¶
type Context ¶
type Context struct {
Namespaces map[string]string // Storage for (private) name spaces
Store map[interface{}]interface{} // Store can be used for private variables accessible in functions
Pos int // Used to determine the position() in the sequence
// contains filtered or unexported fields
}
Context is needed for variables, namespaces and XML navigation.
func CopyContext ¶
CopyContext creates a new context with the underlying xml document but can be changed without changing the original context.
func NewContext ¶
func NewContext(doc *goxml.XMLDocument) *Context
NewContext returns a context from the xml document
func (*Context) Attributes ¶
Attributes returns all attributes of the current node that satisfy the testfunc
func (*Context) CurrentItem ¶ added in v1.0.6
CurrentItem returns the XSLT current() item.
func (*Context) GetContextSequence ¶
GetContextSequence returns the current context.
func (*Context) ResetFrom ¶ added in v1.0.7
ResetFrom reuses an existing context by copying state from src. Unlike CopyContext, it reuses the existing map allocations instead of creating new maps, which reduces GC pressure in tight loops.
func (*Context) SetContextSequence ¶
SetContextSequence sets the context sequence and returns the previous one.
func (*Context) SetCurrentItem ¶ added in v1.0.6
SetCurrentItem sets the XSLT current() item.
type EvalFunc ¶
EvalFunc returns a sequence evaluating the XPath expression in the given context.
func ParseXPath ¶
ParseXPath takes a previously created token list and returns a function that can be used to evaluate the XPath expression in different contexts.
type Function ¶
type Function struct {
Name string
Namespace string
F func(*Context, []Sequence) (Sequence, error)
MinArg int
MaxArg int
}
Function represents an XPath function
type Parser ¶
type Parser struct {
Ctx *Context
}
Parser contains all necessary references to the parser
func (*Parser) Evaluate ¶
Evaluate reads an XPath expression and evaluates it in the given context. Parsed expressions are cached so that repeated evaluation of the same XPath string avoids re-tokenizing and re-parsing.
func (*Parser) SetVariable ¶
SetVariable is used to set a variable name.
func (*Parser) XMLDocument ¶
func (xp *Parser) XMLDocument() *goxml.XMLDocument
XMLDocument returns the underlying XML document
type Sequence ¶
type Sequence []Item
A Sequence is a list of Items
func (Sequence) Stringvalue ¶
Stringvalue returns the concatenation of the string value of each item.
func (Sequence) StringvalueJoin ¶ added in v1.0.5
StringvalueJoin returns the string values of all items joined by sep.
type Tokenlist ¶
type Tokenlist struct {
// contains filtered or unexported fields
}
Tokenlist represents units of XPath language elements.
type XPathArray ¶ added in v1.0.5
type XPathArray struct {
Members []Sequence
}
XPathArray represents an XPath 3.1 array.
func (*XPathArray) Get ¶ added in v1.0.5
func (a *XPathArray) Get(pos int) (Sequence, error)
Get returns the member at the given 1-based index.
func (*XPathArray) Size ¶ added in v1.0.5
func (a *XPathArray) Size() int
Size returns the number of members in the array.
type XPathMap ¶ added in v1.0.5
type XPathMap struct {
Entries []MapEntry
}
XPathMap represents an XPath 3.1 map.
type XSDateTime ¶
XSDateTime is a date time instance
func (XSDateTime) String ¶
func (d XSDateTime) String() string
type XSDuration ¶ added in v1.0.5
type XSDuration struct {
Negative bool
Years int
Months int
Days int
Hours int
Minutes int
Seconds float64
}
XSDuration represents an xs:duration value with separate date and time components.
func ParseXSDuration ¶ added in v1.0.5
func ParseXSDuration(s string) (XSDuration, error)
ParseXSDuration parses an ISO 8601 duration string (e.g. "P1Y2M3DT4H5M6.5S", "-P1Y").
func (XSDuration) String ¶ added in v1.0.5
func (d XSDuration) String() string