@@ -3,12 +3,15 @@ module XML
3
3
using Mmap
4
4
5
5
export
6
- Node, LazyNode, # Core Types
7
- children, parent, nodetype, tag, attributes, value, depth, next, prev, # interface
8
- NodeConstructors # convenience functions for creating Nodes
6
+ # Core Types:
7
+ Node, LazyNode,
8
+ # Interface:
9
+ children, nodetype, tag, attributes, value,
10
+ # Extended Interface for LazyNode:
11
+ parent, depth, next, prev
9
12
10
13
# -----------------------------------------------------------------------------# escape/unescape
11
- # only used by Text nodes
14
+ # only used by Text nodes during `XML.write`
12
15
const escape_chars = (' &' => " &" , ' <' => " <" , ' >' => " >" , " '" => " '" , ' "' => " "" )
13
16
escape (x:: AbstractString ) = replace (x, escape_chars... )
14
17
unescape (x:: AbstractString ) = replace (x, reverse .(escape_chars)... )
@@ -24,6 +27,17 @@ unescape(x::AbstractString) = replace(x, reverse.(escape_chars)...)
24
27
- CData # <![CData[...]]>
25
28
- Element # <NAME attributes... > children... </NAME>
26
29
- Text # text
30
+
31
+ NodeTypes can be used to construct XML.Nodes:
32
+
33
+ Document(children...)
34
+ DTD(value)
35
+ Declaration(; attributes)
36
+ ProcessingInstruction(tag, attributes)
37
+ Comment(text)
38
+ CData(text)
39
+ Element(tag, children...; attributes)
40
+ Text(text)
27
41
"""
28
42
@enum (NodeType, CData, Comment, Declaration, Document, DTD, Element, ProcessingInstruction, Text)
29
43
95
109
Node(node::Node; kw...) # copy node with keyword overrides
96
110
Node(node::LazyNode) # un-lazy the LazyNode
97
111
98
- A representation of an XML DOM node. For convenience constructors, see the `XML.NodeConstructors` module.
112
+ A representation of an XML DOM node. For simpler construction, use `(::NodeType)(args...)`
99
113
"""
100
114
struct Node <: AbstractXMLNode
101
115
nodetype:: NodeType
0 commit comments