Documentation ¶
Index ¶
- Constants
- func Check(path string) (err error)
- func ValueToXPathObject(val interface{}) (ret C.xmlXPathObjectPtr)
- func XPathObjectToValue(obj C.xmlXPathObjectPtr) (result interface{})
- type Expression
- type VariableScope
- type XPath
- func (xpath *XPath) Evaluate(nodePtr unsafe.Pointer, xpathExpr *Expression) (err error)
- func (xpath *XPath) EvaluateAsNodeset(nodePtr unsafe.Pointer, xpathExpr *Expression) (nodes []unsafe.Pointer, err error)
- func (xpath *XPath) Free()
- func (xpath *XPath) GetContextPosition() (position, size int)
- func (xpath *XPath) RegisterNamespace(prefix, href string) bool
- func (xpath *XPath) ResultAsBoolean() (val bool, err error)
- func (xpath *XPath) ResultAsNodeset() (nodes []unsafe.Pointer, err error)
- func (xpath *XPath) ResultAsNumber() (val float64, err error)
- func (xpath *XPath) ResultAsString() (val string, err error)
- func (xpath *XPath) ReturnType() XPathObjectType
- func (xpath *XPath) SetContextPosition(position, size int)
- func (xpath *XPath) SetResolver(v VariableScope)
- type XPathFunction
- type XPathObjectType
Constants ¶
const ( XPATH_UNDEFINED XPathObjectType = 0 XPATH_NODESET = 1 XPATH_BOOLEAN = 2 XPATH_NUMBER = 3 XPATH_STRING = 4 XPATH_POINT = 5 XPATH_RANGE = 6 XPATH_LOCATIONSET = 7 XPATH_USERS = 8 XPATH_XSLT_TREE = 9 // An XSLT value tree, non modifiable )
Variables ¶
This section is empty.
Functions ¶
func ValueToXPathObject ¶
func ValueToXPathObject(val interface{}) (ret C.xmlXPathObjectPtr)
Convert an arbitrary value into a C.xmlXPathObjectPtr Unrecognised and nil values are converted to empty node sets.
func XPathObjectToValue ¶
func XPathObjectToValue(obj C.xmlXPathObjectPtr) (result interface{})
Types ¶
type Expression ¶
type Expression struct { Ptr *C.xmlXPathCompExpr // contains filtered or unexported fields }
func Compile ¶
func Compile(path string) (expr *Expression)
func (*Expression) Free ¶
func (exp *Expression) Free()
func (*Expression) String ¶
func (exp *Expression) String() string
type VariableScope ¶
type VariableScope interface { ResolveVariable(string, string) interface{} IsFunctionRegistered(string, string) bool ResolveFunction(string, string) XPathFunction }
This interface exist primarily for the benefit of XSLT processors.
type XPath ¶
type XPath struct { ContextPtr *C.xmlXPathContext ResultPtr *C.xmlXPathObject }
func (*XPath) Evaluate ¶
func (xpath *XPath) Evaluate(nodePtr unsafe.Pointer, xpathExpr *Expression) (err error)
Evaluate an XPath. The returned result is stored in the struct. Call ReturnType to discover the type of result, and call one of the ResultAs* functions to return a copy of the result as a particular type.
func (*XPath) EvaluateAsNodeset ¶
func (xpath *XPath) EvaluateAsNodeset(nodePtr unsafe.Pointer, xpathExpr *Expression) (nodes []unsafe.Pointer, err error)
Evaluate an XPath and attempt to consume the result as a nodeset.
func (*XPath) GetContextPosition ¶
This allows values to saved and restored during processing of a document.
func (*XPath) RegisterNamespace ¶
func (*XPath) ResultAsBoolean ¶
Coerce the result into a boolean
func (*XPath) ResultAsNodeset ¶
Get the XPath result as a nodeset.
func (*XPath) ResultAsNumber ¶
Coerce the result into a number
func (*XPath) ResultAsString ¶
Coerce the result into a string
func (*XPath) ReturnType ¶
func (xpath *XPath) ReturnType() XPathObjectType
Determine the actual return type of the XPath evaluation.
func (*XPath) SetContextPosition ¶
SetContextPosition sets the internal values needed to determine the values of position() and last() for the current context node.
func (*XPath) SetResolver ¶
func (xpath *XPath) SetResolver(v VariableScope)
Add a variable resolver.
type XPathFunction ¶
type XPathFunction func(context VariableScope, args []interface{}) interface{}
type XPathObjectType ¶
type XPathObjectType int