本文整理汇总了Golang中github.com/ChrisTrenkamp/goxpath/tree.Node类的典型用法代码示例。如果您正苦于以下问题:Golang Node类的具体用法?Golang Node怎么用?Golang Node使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Node类的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: checkPredRes
func checkPredRes(ret tree.Result, f *xpFilt, node tree.Node) (bool, error) {
if num, ok := ret.(tree.Num); ok {
if float64(f.proxPos[node.Pos()]) == float64(num) {
return true, nil
}
return false, nil
}
if b, ok := ret.(tree.IsBool); ok {
return bool(b.Bool()), nil
}
return false, fmt.Errorf("Cannot convert argument to boolean")
}
示例2: findPrecedingSibling
func findPrecedingSibling(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
return
}
par := x.GetParent()
ch := par.GetChildren()
i := len(ch) - 1
for x != ch[i] {
i--
}
i--
for i >= 0 {
findSelf(ch[i], p, ret)
i--
}
}
示例3: findFollowingSibling
func findFollowingSibling(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
return
}
par := x.GetParent()
ch := par.GetChildren()
i := 0
for x != ch[i] {
i++
}
i++
for i < len(ch) {
findSelf(ch[i], p, ret)
i++
}
}
示例4: findAncestor
func findAncestor(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() == tree.NtRoot {
return
}
addNode(x.GetParent(), p, ret)
findAncestor(x.GetParent(), p, ret)
}
示例5: addNode
func addNode(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
add := false
tok := x.GetToken()
switch x.GetNodeType() {
case tree.NtAttr:
add = evalAttr(p, tok.(xml.Attr))
case tree.NtChd:
add = evalChd(p)
case tree.NtComm:
add = evalComm(p)
case tree.NtElem, tree.NtRoot:
add = evalEle(p, tok.(xml.StartElement))
case tree.NtNs:
add = evalNS(p, tok.(xml.Attr))
case tree.NtPi:
add = evalPI(p)
}
if add {
*ret = append(*ret, x)
}
}
示例6: encTok
func encTok(n tree.Node, e *xml.Encoder) error {
switch n.GetNodeType() {
case tree.NtAttr:
return encAttr(n.GetToken().(xml.Attr), e)
case tree.NtElem:
return encEle(n.(tree.Elem), e)
case tree.NtNs:
return encNS(n.GetToken().(xml.Attr), e)
case tree.NtRoot:
for _, i := range n.(tree.Elem).GetChildren() {
err := encTok(i, e)
if err != nil {
return err
}
}
return nil
}
//case tree.NtChd, tree.NtComm, tree.NtPi:
return e.EncodeToken(n.GetToken())
}
示例7: findParent
func findParent(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
if x.GetNodeType() != tree.NtRoot {
addNode(x.GetParent(), p, ret)
}
}