當前位置: 首頁>>代碼示例>>Golang>>正文


Golang tree.Node類代碼示例

本文整理匯總了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")
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:14,代碼來源:paths.go

示例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--
	}
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:16,代碼來源:findUtil.go

示例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++
	}
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:16,代碼來源:findUtil.go

示例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)
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:8,代碼來源:findUtil.go

示例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)
	}
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:23,代碼來源:findUtil.go

示例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())
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:21,代碼來源:marshal.go

示例7: findParent

func findParent(x tree.Node, p *pathexpr.PathExpr, ret *[]tree.Node) {
	if x.GetNodeType() != tree.NtRoot {
		addNode(x.GetParent(), p, ret)
	}
}
開發者ID:ChrisTrenkamp,項目名稱:goxpath,代碼行數:5,代碼來源:findUtil.go


注:本文中的github.com/ChrisTrenkamp/goxpath/tree.Node類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。