forked from lestrrat-go/libxml2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
interface.go
100 lines (81 loc) · 1.93 KB
/
interface.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
package dom
import (
"errors"
"github.com/wayf-dk/go-libxml2/clib"
)
var (
ErrAttributeNotFound = errors.New("attribute not found")
ErrInvalidNodeType = errors.New("invalid node type")
)
// XMLNodeType identifies the type of the underlying C struct
type XMLNodeType clib.XMLNodeType
const (
ElementNode = clib.ElementNode
AttributeNode = clib.AttributeNode
TextNode = clib.TextNode
CDataSectionNode = clib.CDataSectionNode
EntityRefNode = clib.EntityRefNode
EntityNode = clib.EntityNode
PiNode = clib.PiNode
CommentNode = clib.CommentNode
DocumentNode = clib.DocumentNode
DocumentTypeNode = clib.DocumentTypeNode
DocumentFragNode = clib.DocumentFragNode
NotationNode = clib.NotationNode
HTMLDocumentNode = clib.HTMLDocumentNode
DTDNode = clib.DTDNode
ElementDecl = clib.ElementDecl
AttributeDecl = clib.AttributeDecl
EntityDecl = clib.EntityDecl
NamespaceDecl = clib.NamespaceDecl
XIncludeStart = clib.XIncludeStart
XIncludeEnd = clib.XIncludeEnd
DocbDocumentNode = clib.DocbDocumentNode
)
type XMLNode struct {
ptr uintptr // *C.xmlNode
mortal bool
}
type Attribute struct {
XMLNode
}
type CDataSection struct {
XMLNode
}
type Pi struct {
XMLNode
}
type Comment struct {
XMLNode
}
type Element struct {
XMLNode
}
type Document struct {
ptr uintptr // *C.xmlDoc
mortal bool
}
type Text struct {
XMLNode
}
type Namespace struct {
XMLNode
}
type Serializer interface {
Serialize(interface{}) (string, error)
}
// note: Serialize takes an interface because some serializers only allow
// Document, whereas others might allow Nodes
// C14NMode represents the C14N mode supported by libxml2
type C14NMode int
const (
C14N1_0 C14NMode = iota
C14NExclusive1_0
C14N1_1
)
// C14NSerialize implements the Serializer interface, and generates
// XML in C14N format.
type C14NSerialize struct {
Mode C14NMode
WithComments bool
}