本文整理匯總了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)
}
}