Skip to content

Commit d7f456b

Browse files
committed
reorg
1 parent 71becd9 commit d7f456b

File tree

4 files changed

+478
-507
lines changed

4 files changed

+478
-507
lines changed

README.md

Lines changed: 17 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -8,19 +8,20 @@
88

99
This package offers fast data structures for reading and writing XML files with a consistent interface:
1010

11-
#### Interface Core:
11+
#### `Node`/`LazyNode` Interface:
1212

13-
- `nodetype(node) --> XML.NodeType` (See `?XML.NodeType` for details).
14-
- `tag(node) --> String or Nothing`
15-
- `attributes(node) --> OrderedDict{String,String} or Nothing`
16-
- `value(node) --> String or Nothing`
17-
- `children(node) --> Vector{typeof(node)}`
18-
- `depth(node) --> Int`
13+
- `nodetype(node) → XML.NodeType` (See `?XML.NodeType` for details).
14+
- `tag(node) → String or Nothing`
15+
- `attributes(node) → Dict{String,String} or Nothing`
16+
- `value(node) → String or Nothing`
17+
- `children(node) → Vector{typeof(node)}`
1918

20-
#### Interface for Lazy Data Structures:
21-
- `next(node) --> typeof(node)`
22-
- `prev(node) --> typeof(node)`
23-
- `parent(node) --> typeof(node)`
19+
#### Extended Interface for `LazyNode`
20+
21+
- `depth(node) → Int`
22+
- `next(node) → typeof(node)`
23+
- `prev(node) → typeof(node)`
24+
- `parent(node) → typeof(node)`
2425

2526
## Quickstart
2627

@@ -29,11 +30,11 @@ using XML
2930

3031
filename = joinpath(dirname(pathof(XML)), "..", "test", "books.xml")
3132

32-
doc = XML.Node(filename)
33+
doc = Node(filename)
3334

3435
children(doc)
3536
# 2-element Vector{Node}:
36-
# Node DECLARATION <?xml version="1.0">
37+
# Node DECLARATION <?xml version="1.0"?>
3738
# Node ELEMENT <catalog> (12 children)
3839

3940
doc[end] # The root node
@@ -43,11 +44,12 @@ doc[end][2] # Second child of root
4344
# Node ELEMENT <book id="bk102"> (6 children)
4445
```
4546

46-
## Data Structures
47+
## Node Types
4748

4849
### `XML.Node`
50+
4951
- An eager data structure that loads the entire XML DOM in memory.
50-
- **This is what you should use to build an XML document programmatically.**
52+
- **This is what you would use to build an XML document programmatically.**
5153
- `Node`s have some additional methods that aid in construction/mutation:
5254

5355
```julia
@@ -56,15 +58,6 @@ push!(parent::Node, child::Node)
5658

5759
# Replace a child:
5860
parent[2] = child
59-
60-
# Create a new node with an edited field. `kw...` can be one or more of:
61-
# - nodetype::NodeType
62-
# - tag (String or Nothing)
63-
# - attributes (OrderedDict{String,String} or Nothing)
64-
# - value (String or Nothing)
65-
# - children (Vector{Node} or nothing),
66-
# - depth::Int (this will be automatically set if not provided)
67-
Node(node; kw...)
6861
```
6962

7063
- Bring convenience functions into your namespace with `using XML.NodeConstructors`:

benchmarks/suite.jl

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,19 @@ using XMLDict: XMLDict
44
using BenchmarkTools
55

66

7-
file = download("http://schemas.opengis.net/kml/2.2.0/ogckml22.xsd")
7+
# http://aiweb.cs.washington.edu/research/projects/xmltk/xmldata/www/repository.html#nasa
8+
file = joinpath(@__DIR__, "nasa.xml")
89

910
#-----------------------------------------------------------------------------# Read
1011
@info "XML.Raw" @benchmark XML.Raw($file)
11-
@info "XML.FastNode" @benchmark XML.FastNode($file)
12-
@info "XML.Node" @benchmark Node($file)
13-
@info "XML.RowNode" @benchmark XML.RowNode($file)
14-
@info "EzXML.readxml" @benchmark EzXML.readxml($file)
15-
@info "XMLDict.xml_dict" @benchmark XMLDict.xml_dict(read($file, String))
12+
@info "XML.LazyNode" @benchmark XML.LazyNode($file)
13+
# @info "XML.Node" @benchmark Node($file)
14+
# @info "XML.RowNode" @benchmark XML.RowNode($file)
15+
# @info "EzXML.readxml" @benchmark EzXML.readxml($file)
16+
# @info "XMLDict.xml_dict" @benchmark XMLDict.xml_dict(read($file, String))
1617

17-
#-----------------------------------------------------------------------------# Iteration
18-
@info "XML.RawData iteration" @benchmark (for x in XML.RawData($file); end)
19-
@info "XML.RowNode iteration" @benchmark (for x in XML.RowNode($file); end)
18+
# #-----------------------------------------------------------------------------# Iteration
19+
# @info "XML.RawData iteration" @benchmark (for x in XML.RawData($file); end)
20+
# @info "XML.RowNode iteration" @benchmark (for x in XML.RowNode($file); end)
2021

21-
@info "EzXML.StreamReader" @benchmark (reader = open(EzXML.StreamReader, $file); for x in reader; end; close(reader))
22+
# @info "EzXML.StreamReader" @benchmark (reader = open(EzXML.StreamReader, $file); for x in reader; end; close(reader))

0 commit comments

Comments
 (0)