func (f *functionQuery) Evaluate(t iterator) interface{} {
	return f.Func(f.Input, t)
}
Evaluate call a specified function that will returns the
following value type: number,string,boolean.
package xpath
import (
	"bytes"
	"fmt"
	"hash/fnv"
	"reflect"
)
type iterator interface {
	Current() NodeNavigator
}
type query interface {
	Select(iterator) NodeNavigator
	Evaluate(iterator) interface{}
	Clone() query
}
type nopQuery struct {
	query
}
func (nopQuery) Select(iterator) NodeNavigator { return nil }
func (nopQuery) Evaluate(iterator) interface{} { return nil }
func (nopQuery) Clone() query { return nopQuery{} }
type contextQuery struct {
	count int
	Root  bool  
}
func (c *contextQuery) Select(t iterator) (n NodeNavigator) {
	if c.count == 0 {
		c.count++
		n = t.Current().Copy()
		if c.Root {
			n.MoveToRoot()
		}
	}
	return n
}
func (c *contextQuery) Evaluate(iterator) interface{} {
	c.count = 0
	return c
}
func (c *contextQuery) Clone() query {
	return &contextQuery{count: 0, Root: c.Root}
}
type ancestorQuery struct {
	iterator func() NodeNavigator
	Self      bool
	Input     query
	Predicate func(NodeNavigator) bool
}
func (a *ancestorQuery) Select(t iterator) NodeNavigator {
	for {
		if a.iterator == nil {
			node := a.Input.Select(t)
			if node == nil {
				return nil
			}
			first := true
			node = node.Copy()
			a.iterator = func() NodeNavigator {
				if first && a.Self {
					first = false
					if a.Predicate(node) {
						return node
					}
				}
				for node.MoveToParent() {
					if !a.Predicate(node) {
						continue
					}
					return node
				}
				return nil
			}
		}
		if node := a.iterator(); node != nil {
			return node
		}
		a.iterator = nil
	}
}
func (a *ancestorQuery) Evaluate(t iterator) interface{} {
	a.Input.Evaluate(t)
	a.iterator = nil
	return a
}
func (a *ancestorQuery) Test(n NodeNavigator) bool {
	return a.Predicate(n)
}
func (a *ancestorQuery) Clone() query {
	return &ancestorQuery{Self: a.Self, Input: a.Input.Clone(), Predicate: a.Predicate}
}
type attributeQuery struct {
	iterator func() NodeNavigator
	Input     query
	Predicate func(NodeNavigator) bool
}
func (a *attributeQuery) Select(t iterator) NodeNavigator {
	for {
		if a.iterator == nil {
			node := a.Input.Select(t)
			if node == nil {
				return nil
			}
			node = node.Copy()
			a.iterator = func() NodeNavigator {
				for {
					onAttr := node.MoveToNextAttribute()
					if !onAttr {
						return nil
					}
					if a.Predicate(node) {
						return node
					}
				}
			}
		}
		if node := a.iterator(); node != nil {
			return node
		}
		a.iterator = nil
	}
}
func (a *attributeQuery) Evaluate(t iterator) interface{} {
	a.Input.Evaluate(t)
	a.iterator = nil
	return a
}
func (a *attributeQuery) Test(n NodeNavigator) bool {
	return a.Predicate(n)
}
func (a *attributeQuery) Clone() query {
	return &attributeQuery{Input: a.Input.Clone(), Predicate: a.Predicate}
}
type childQuery struct {
	posit    int
	iterator func() NodeNavigator
	Input     query
	Predicate func(NodeNavigator) bool
}
func (c *childQuery) Select(t iterator) NodeNavigator {
	for {
		if c.iterator == nil {
			c.posit = 0
			node := c.Input.Select(t)
			if node == nil {
				return nil
			}
			node = node.Copy()
			first := true
			c.iterator = func() NodeNavigator {
				for {
					if (first && !node.MoveToChild()) || (!first && !node.MoveToNext()) {
						return nil
					}
					first = false
					if c.Predicate(node) {
						return node
					}
				}
			}
		}
		if node := c.iterator(); node != nil {
			c.posit++
			return node
		}
		c.iterator = nil
	}
}
func (c *childQuery) Evaluate(t iterator) interface{} {
	c.Input.Evaluate(t)
	c.iterator = nil
	return c
}
func (c *childQuery) Test(n NodeNavigator) bool {
	return c.Predicate(n)
}
func (c *childQuery) Clone() query {
	return &childQuery{Input: c.Input.Clone(), Predicate: c.Predicate}
}
func (c *childQuery) position() int {
	return c.posit
}
type descendantQuery struct {
	iterator func() NodeNavigator
	posit    int
	level    int
	Self      bool
	Input     query
	Predicate func(NodeNavigator) bool
}
func (d *descendantQuery) Select(t iterator) NodeNavigator {
	for {
		if d.iterator == nil {
			d.posit = 0
			node := d.Input.Select(t)
			if node == nil {
				return nil
			}
			node = node.Copy()
			d.level = 0
			positmap := make(map[int]int)
			first := true
			d.iterator = func() NodeNavigator {
				if first && d.Self {
					first = false
					if d.Predicate(node) {
						d.posit = 1
						positmap[d.level] = 1
						return node
					}
				}
				for {
					if node.MoveToChild() {
						d.level = d.level + 1
						positmap[d.level] = 0
					} else {
						for {
							if d.level == 0 {
								return nil
							}
							if node.MoveToNext() {
								break
							}
							node.MoveToParent()
							d.level = d.level - 1
						}
					}
					if d.Predicate(node) {
						positmap[d.level]++
						d.posit = positmap[d.level]
						return node
					}
				}
			}
		}
		if node := d.iterator(); node != nil {
			return node
		}
		d.iterator = nil
	}
}
func (d *descendantQuery) Evaluate(t iterator) interface{} {
	d.Input.Evaluate(t)
	d.iterator = nil
	return d
}
func (d *descendantQuery) Test(n NodeNavigator) bool {
	return d.Predicate(n)
}
func (d *descendantQuery) position() int {
	return d.posit
}
func (d *descendantQuery) depth() int {
	return d.level
}
func (d *descendantQuery) Clone() query {
	return &descendantQuery{Self: d.Self, Input: d.Input.Clone(), Predicate: d.Predicate}
}
type followingQuery struct {
	posit    int
	iterator func() NodeNavigator
	Input     query
	Sibling   bool  
	Predicate func(NodeNavigator) bool
}
func (f *followingQuery) Select(t iterator) NodeNavigator {
	for {
		if f.iterator == nil {
			f.posit = 0
			node := f.Input.Select(t)
			if node == nil {
				return nil
			}
			node = node.Copy()
			if f.Sibling {
				f.iterator = func() NodeNavigator {
					for {
						if !node.MoveToNext() {
							return nil
						}
						if f.Predicate(node) {
							f.posit++
							return node
						}
					}
				}
			} else {
				var q *descendantQuery  
				f.iterator = func() NodeNavigator {
					for {
						if q == nil {
							for !node.MoveToNext() {
								if !node.MoveToParent() {
									return nil
								}
							}
							q = &descendantQuery{
								Self:      true,
								Input:     &contextQuery{},
								Predicate: f.Predicate,
							}
							t.Current().MoveTo(node)
						}
						if node := q.Select(t); node != nil {
							f.posit = q.posit
							return node
						}
						q = nil
					}
				}
			}
		}
		if node := f.iterator(); node != nil {
			return node
		}
		f.iterator = nil
	}
}
func (f *followingQuery) Evaluate(t iterator) interface{} {
	f.Input.Evaluate(t)
	return f
}
func (f *followingQuery) Test(n NodeNavigator) bool {
	return f.Predicate(n)
}
func (f *followingQuery) Clone() query {
	return &followingQuery{Input: f.Input.Clone(), Sibling: f.Sibling, Predicate: f.Predicate}
}
func (f *followingQuery) position() int {
	return f.posit
}
type precedingQuery struct {
	iterator  func() NodeNavigator
	posit     int
	Input     query
	Sibling   bool  
	Predicate func(NodeNavigator) bool
}
func (p *precedingQuery) Select(t iterator) NodeNavigator {
	for {
		if p.iterator == nil {
			p.posit = 0
			node := p.Input.Select(t)
			if node == nil {
				return nil
			}
			node = node.Copy()
			if p.Sibling {
				p.iterator = func() NodeNavigator {
					for {
						for !node.MoveToPrevious() {
							return nil
						}
						if p.Predicate(node) {
							p.posit++
							return node
						}
					}
				}
			} else {
				var q query
				p.iterator = func() NodeNavigator {
					for {
						if q == nil {
							for !node.MoveToPrevious() {
								if !node.MoveToParent() {
									return nil
								}
								p.posit = 0
							}
							q = &descendantQuery{
								Self:      true,
								Input:     &contextQuery{},
								Predicate: p.Predicate,
							}
							t.Current().MoveTo(node)
						}
						if node := q.Select(t); node != nil {
							p.posit++
							return node
						}
						q = nil
					}
				}
			}
		}
		if node := p.iterator(); node != nil {
			return node
		}
		p.iterator = nil
	}
}
func (p *precedingQuery) Evaluate(t iterator) interface{} {
	p.Input.Evaluate(t)
	return p
}
func (p *precedingQuery) Test(n NodeNavigator) bool {
	return p.Predicate(n)
}
func (p *precedingQuery) Clone() query {
	return &precedingQuery{Input: p.Input.Clone(), Sibling: p.Sibling, Predicate: p.Predicate}
}
func (p *precedingQuery) position() int {
	return p.posit
}
type parentQuery struct {
	Input     query
	Predicate func(NodeNavigator) bool
}
func (p *parentQuery) Select(t iterator) NodeNavigator {
	for {
		node := p.Input.Select(t)
		if node == nil {
			return nil
		}
		node = node.Copy()
		if node.MoveToParent() && p.Predicate(node) {
			return node
		}
	}
}
func (p *parentQuery) Evaluate(t iterator) interface{} {
	p.Input.Evaluate(t)
	return p
}
func (p *parentQuery) Clone() query {
	return &parentQuery{Input: p.Input.Clone(), Predicate: p.Predicate}
}
func (p *parentQuery) Test(n NodeNavigator) bool {
	return p.Predicate(n)
}
type selfQuery struct {
	Input     query
	Predicate func(NodeNavigator) bool
}
func (s *selfQuery) Select(t iterator) NodeNavigator {
	for {
		node := s.Input.Select(t)
		if node == nil {
			return nil
		}
		if s.Predicate(node) {
			return node
		}
	}
}
func (s *selfQuery) Evaluate(t iterator) interface{} {
	s.Input.Evaluate(t)
	return s
}
func (s *selfQuery) Test(n NodeNavigator) bool {
	return s.Predicate(n)
}
func (s *selfQuery) Clone() query {
	return &selfQuery{Input: s.Input.Clone(), Predicate: s.Predicate}
}
type filterQuery struct {
	Input     query
	Predicate query
	posit     int
	positmap  map[int]int
}
func (f *filterQuery) do(t iterator) bool {
	val := reflect.ValueOf(f.Predicate.Evaluate(t))
	switch val.Kind() {
	case reflect.Bool:
		return val.Bool()
	case reflect.String:
		return len(val.String()) > 0
	case reflect.Float64:
		pt := getNodePosition(f.Input)
		return int(val.Float()) == pt
	default:
		if q, ok := f.Predicate.(query); ok {
			return q.Select(t) != nil
		}
	}
	return false
}
func (f *filterQuery) position() int {
	return f.posit
}
func (f *filterQuery) Select(t iterator) NodeNavigator {
	if f.positmap == nil {
		f.positmap = make(map[int]int)
	}
	for {
		node := f.Input.Select(t)
		if node == nil {
			return node
		}
		node = node.Copy()
		t.Current().MoveTo(node)
		if f.do(t) {
			level := getNodeDepth(f.Input)
			f.positmap[level]++
			f.posit = f.positmap[level]
			return node
		}
	}
}
func (f *filterQuery) Evaluate(t iterator) interface{} {
	f.Input.Evaluate(t)
	return f
}
func (f *filterQuery) Clone() query {
	return &filterQuery{Input: f.Input.Clone(), Predicate: f.Predicate.Clone()}
}
type functionQuery struct {
	Input query                              
	Func  func(query, iterator) interface{}  
}
func (f *functionQuery) Select(t iterator) NodeNavigator {
	return nil
}