-
Notifications
You must be signed in to change notification settings - Fork 0
/
basicattr.go
82 lines (66 loc) · 1.94 KB
/
basicattr.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
package dom
type BasicAttr struct {
basicNode
name Name
value string
}
var _ Attr = &BasicAttr{}
// Returns a boolean value indicating whether or not the two nodes are
// the same (that is, they reference the same object).
func (attr *BasicAttr) IsSameNode(node Node) bool { return node == attr }
// A String representing the local part of the qualified name of the
// attribute.
func (attr *BasicAttr) GetLocalName() string {
return attr.name.Local
}
// Returns the qualified name of an attribute, that is the name of
// the attribute, with the namespace prefix, if any, in front of
// it. For example, if the local name is lang and the namespace
// prefix is xml, the returned qualified name is xml:lang.
func (attr *BasicAttr) GetName() string {
return attr.name.QName()
}
func (attr *BasicAttr) GetQName() Name {
return attr.name
}
// The Element the attribute belongs to.
func (attr *BasicAttr) GetOwnerElement() Element {
if el, ok := attr.parent.(Element); ok {
return el
}
return nil
}
// The attribute's value, a string that can be set and get using this
// property.
func (attr *BasicAttr) GetValue() string {
return attr.value
}
func (attr *BasicAttr) SetValue(v string) {
attr.value = v
}
func (attr *BasicAttr) CloneNode(bool) Node {
return attr.cloneNode(attr.ownerDocument, false)
}
func (attr *BasicAttr) cloneNode(owner Document, deep bool) Node {
ret := BasicAttr{
basicNode: basicNode{
ownerDocument: owner.(*BasicDocument),
},
name: attr.name,
value: attr.value,
}
return &ret
}
func (attr *BasicAttr) GetNodeName() string {
return attr.GetName()
}
func (attr *BasicAttr) GetNodeType() NodeType { return ATTRIBUTE_NODE }
// Returns a boolean value which indicates whether or not two nodes
// are of the same type and all their defining data points match.
func (attr *BasicAttr) IsEqualNode(node Node) bool {
a, ok := node.(*BasicAttr)
if !ok {
return false
}
return a.name == attr.name && a.value == attr.value
}