-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprocinst.go
166 lines (132 loc) · 3.38 KB
/
procinst.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
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
package dom
import "fmt"
type domProcInst struct {
ownerDocument Document
parentNode Node
data string
target string
}
func newProcInst(owner Document, target string, data string) ProcessingInstruction {
// TODO: validation of target and data, such as invalid characters (<? and ?> etc)
pi := &domProcInst{}
pi.ownerDocument = owner
pi.target = target
pi.data = data
return pi
}
func (pi *domProcInst) GetNodeName() string {
return pi.GetTarget()
}
func (pi *domProcInst) GetNodeType() NodeType {
return ProcessingInstructionNode
}
// GetNodeValue returns the processing instruction's data.
func (pi *domProcInst) GetNodeValue() string {
return pi.GetData()
}
func (pi *domProcInst) GetLocalName() string {
// TODO: what?
return ""
}
func (pi *domProcInst) GetChildNodes() []Node {
return nil
}
func (pi *domProcInst) GetParentNode() Node {
return pi.parentNode
}
func (pi *domProcInst) GetFirstChild() Node {
return nil
}
func (pi *domProcInst) GetLastChild() Node {
return nil
}
func (pi *domProcInst) GetAttributes() NamedNodeMap {
return nil
}
func (pi *domProcInst) HasAttributes() bool {
return false
}
func (pi *domProcInst) GetOwnerDocument() Document {
return pi.ownerDocument
}
func (pi *domProcInst) AppendChild(child Node) error {
return ErrorHierarchyRequest
}
func (pi *domProcInst) RemoveChild(oldChild Node) (Node, error) {
return nil, ErrorHierarchyRequest
}
func (pi *domProcInst) ReplaceChild(newChild, oldChild Node) (Node, error) {
return nil, ErrorHierarchyRequest
}
func (pi *domProcInst) InsertBefore(newChild, refChild Node) (Node, error) {
return nil, ErrorHierarchyRequest
}
func (pi *domProcInst) HasChildNodes() bool {
return false
}
func (pi *domProcInst) GetPreviousSibling() Node {
return getPreviousSibling(pi)
}
func (pi *domProcInst) GetNextSibling() Node {
return getNextSibling(pi)
}
func (pi *domProcInst) GetNamespaceURI() string {
return ""
}
func (pi *domProcInst) GetNamespacePrefix() string {
return ""
}
func (pi *domProcInst) LookupPrefix(namespace string) (string, bool) {
if pi.GetParentNode() != nil {
return pi.LookupPrefix(namespace)
}
return "", false
}
func (pi *domProcInst) LookupNamespaceURI(pfx string) (string, bool) {
if pi.GetParentNode() != nil {
return pi.LookupNamespaceURI(pfx)
}
return "", false
}
func (pi *domProcInst) IsDefaultNamespace(namespace string) bool {
// TODO ?
return false
}
// ProcessingInstruction methods
func (pi *domProcInst) GetData() string {
return pi.data
}
func (pi *domProcInst) GetTarget() string {
return pi.target
}
func (pi *domProcInst) SetData(data string) {
pi.data = data
}
func (pi *domProcInst) setTarget(target string) {
pi.target = target
}
func (pi *domProcInst) GetTextContent() string {
return ""
}
func (pi *domProcInst) SetTextContent(content string) {
// no-op
}
func (pi *domProcInst) CloneNode(deep bool) Node {
clonePi, err := pi.ownerDocument.CreateProcessingInstruction(pi.target, pi.data)
if err != nil {
panic("CreateProcessingInstruction returned an unexpected error")
}
return clonePi
}
func (pi *domProcInst) ImportNode(n Node, deep bool) Node {
return nil
}
func (pi *domProcInst) setParentNode(parent Node) {
pi.parentNode = parent
}
func (pi *domProcInst) setOwnerDocument(doc Document) {
pi.ownerDocument = doc
}
func (pi *domProcInst) String() string {
return fmt.Sprintf("%s: '%s'='%s'", pi.GetNodeType(), pi.target, pi.data)
}