xmlparser 0.6.81
Sign up to get free protection for your applications and to get access to all the features.
- data/MANIFEST +112 -0
- data/README +697 -0
- data/README.ja +789 -0
- data/Rakefile +34 -0
- data/ext/encoding.h +91 -0
- data/ext/xmlparser/mkrf_conf.rb +28 -0
- data/ext/xmlparser/xmlparser.c +2226 -0
- data/lib/sax.rb +1 -0
- data/lib/saxdriver.rb +1 -0
- data/lib/wget.rb +47 -0
- data/lib/xml/dom/builder-ja.rb +58 -0
- data/lib/xml/dom/builder.rb +310 -0
- data/lib/xml/dom/core.rb +3276 -0
- data/lib/xml/dom/digest.rb +94 -0
- data/lib/xml/dom/visitor.rb +182 -0
- data/lib/xml/dom2/attr.rb +213 -0
- data/lib/xml/dom2/cdatasection.rb +76 -0
- data/lib/xml/dom2/characterdata.rb +177 -0
- data/lib/xml/dom2/comment.rb +81 -0
- data/lib/xml/dom2/core.rb +19 -0
- data/lib/xml/dom2/document.rb +317 -0
- data/lib/xml/dom2/documentfragment.rb +82 -0
- data/lib/xml/dom2/documenttype.rb +102 -0
- data/lib/xml/dom2/dombuilder.rb +277 -0
- data/lib/xml/dom2/dombuilderfilter.rb +12 -0
- data/lib/xml/dom2/domentityresolver.rb +13 -0
- data/lib/xml/dom2/domentityresolverimpl.rb +37 -0
- data/lib/xml/dom2/domexception.rb +95 -0
- data/lib/xml/dom2/domimplementation.rb +61 -0
- data/lib/xml/dom2/dominputsource.rb +29 -0
- data/lib/xml/dom2/element.rb +533 -0
- data/lib/xml/dom2/entity.rb +110 -0
- data/lib/xml/dom2/entityreference.rb +107 -0
- data/lib/xml/dom2/namednodemap.rb +138 -0
- data/lib/xml/dom2/node.rb +587 -0
- data/lib/xml/dom2/nodelist.rb +231 -0
- data/lib/xml/dom2/notation.rb +86 -0
- data/lib/xml/dom2/processinginstruction.rb +155 -0
- data/lib/xml/dom2/text.rb +128 -0
- data/lib/xml/dom2/xpath.rb +398 -0
- data/lib/xml/encoding-ja.rb +42 -0
- data/lib/xml/parser.rb +13 -0
- data/lib/xml/parserns.rb +236 -0
- data/lib/xml/sax.rb +353 -0
- data/lib/xml/saxdriver.rb +370 -0
- data/lib/xml/xpath.rb +3284 -0
- data/lib/xml/xpath.ry +2352 -0
- data/lib/xmldigest.rb +1 -0
- data/lib/xmltree.rb +1 -0
- data/lib/xmltreebuilder.rb +1 -0
- data/lib/xmltreevisitor.rb +1 -0
- metadata +111 -0
@@ -0,0 +1,231 @@
|
|
1
|
+
## -*- Ruby -*-
|
2
|
+
## XML::DOM
|
3
|
+
## 1998-2001 by yoshidam
|
4
|
+
##
|
5
|
+
|
6
|
+
module XML
|
7
|
+
module DOM
|
8
|
+
=begin
|
9
|
+
== Class XML::DOM::NodeList
|
10
|
+
|
11
|
+
|
12
|
+
=end
|
13
|
+
class NodeList
|
14
|
+
|
15
|
+
=begin
|
16
|
+
=== Class Methods
|
17
|
+
|
18
|
+
--- NodeList.new(nodes = nil)
|
19
|
+
|
20
|
+
creates a new NodeList.
|
21
|
+
=end
|
22
|
+
def initialize(nodes = nil)
|
23
|
+
if nodes.nil?
|
24
|
+
@nodes = []
|
25
|
+
elsif nodes.is_a?(Array)
|
26
|
+
@nodes = nodes
|
27
|
+
else
|
28
|
+
raise "parameter error"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
=begin
|
33
|
+
=== Methods
|
34
|
+
|
35
|
+
--- NodeList#item(index)
|
36
|
+
|
37
|
+
[DOM]
|
38
|
+
return the indexth item in the NodeList.
|
39
|
+
=end
|
40
|
+
## [DOM]
|
41
|
+
def item(index)
|
42
|
+
@nodes[index]
|
43
|
+
end
|
44
|
+
|
45
|
+
=begin
|
46
|
+
--- NodeList#size()
|
47
|
+
|
48
|
+
return size of NodeList.
|
49
|
+
=end
|
50
|
+
def size
|
51
|
+
@nodes.length
|
52
|
+
end
|
53
|
+
alias length size
|
54
|
+
|
55
|
+
=begin
|
56
|
+
--- NodeList#[](index)
|
57
|
+
|
58
|
+
return indexth node of the NodeList.
|
59
|
+
=end
|
60
|
+
def [](index)
|
61
|
+
@nodes[index]
|
62
|
+
end
|
63
|
+
|
64
|
+
=begin
|
65
|
+
--- NodeList#[]=(*p)
|
66
|
+
|
67
|
+
set node of indexth node of the NodeList.
|
68
|
+
=end
|
69
|
+
def []=(*p)
|
70
|
+
if p.length == 2
|
71
|
+
@nodes[p[0]] = p[1]
|
72
|
+
elsif p.length == 3
|
73
|
+
@nodes[p[0], p[1]] = p[2]
|
74
|
+
end
|
75
|
+
end
|
76
|
+
|
77
|
+
=begin
|
78
|
+
--- NodeList#each
|
79
|
+
|
80
|
+
iterates over each node of the NodeList.
|
81
|
+
=end
|
82
|
+
def each
|
83
|
+
@nodes.each do |value|
|
84
|
+
yield(value)
|
85
|
+
end
|
86
|
+
end
|
87
|
+
|
88
|
+
=begin
|
89
|
+
--- NodeList#reversible_each(reverse = false)
|
90
|
+
|
91
|
+
iterates over each node of the reversed NodeList.
|
92
|
+
=end
|
93
|
+
## [Masaki Fukushima]
|
94
|
+
def reversible_each(reverse = false)
|
95
|
+
if !reverse
|
96
|
+
@nodes.each do |value|
|
97
|
+
yield(value)
|
98
|
+
end
|
99
|
+
else
|
100
|
+
@nodes.reverse_each do |value|
|
101
|
+
yield(value)
|
102
|
+
end
|
103
|
+
end
|
104
|
+
end
|
105
|
+
|
106
|
+
=begin
|
107
|
+
--- NodeList#push(*nodes)
|
108
|
+
|
109
|
+
adds nodes into the NodeList.
|
110
|
+
=end
|
111
|
+
def push(*nodes)
|
112
|
+
nodes.each do |node|
|
113
|
+
if node.is_a?(Array)
|
114
|
+
self.push(*node)
|
115
|
+
elsif node.is_a?(NodeList)
|
116
|
+
@nodes.concat(node.to_a)
|
117
|
+
elsif node.is_a?(Node)
|
118
|
+
@nodes << node
|
119
|
+
else
|
120
|
+
raise "parameter error"
|
121
|
+
end
|
122
|
+
end
|
123
|
+
self
|
124
|
+
end
|
125
|
+
|
126
|
+
=begin
|
127
|
+
--- NodeList#concat(*nodes)
|
128
|
+
|
129
|
+
alias of NodeList#push.
|
130
|
+
=end
|
131
|
+
alias concat push
|
132
|
+
|
133
|
+
=begin
|
134
|
+
--- NodeList#pop
|
135
|
+
|
136
|
+
pops and returns the last node of the NodeList.
|
137
|
+
=end
|
138
|
+
def pop
|
139
|
+
@nodes.pop
|
140
|
+
end
|
141
|
+
|
142
|
+
=begin
|
143
|
+
--- NodeList#shift
|
144
|
+
|
145
|
+
removes and returns the first node of the NodeList.
|
146
|
+
=end
|
147
|
+
def shift
|
148
|
+
@nodes.shift
|
149
|
+
end
|
150
|
+
|
151
|
+
=begin
|
152
|
+
--- NodeList#to_s
|
153
|
+
|
154
|
+
returns the string representation of the NodeList.
|
155
|
+
=end
|
156
|
+
def to_s
|
157
|
+
@nodes.to_s
|
158
|
+
end
|
159
|
+
|
160
|
+
=begin
|
161
|
+
--- NodeList#reverse
|
162
|
+
|
163
|
+
returns the reversed NodeList.
|
164
|
+
=end
|
165
|
+
def reverse
|
166
|
+
@nodes.reverse
|
167
|
+
end
|
168
|
+
|
169
|
+
=begin
|
170
|
+
--- NodeList#to_a
|
171
|
+
|
172
|
+
converts the NodeList into an array.
|
173
|
+
=end
|
174
|
+
def to_a
|
175
|
+
@nodes
|
176
|
+
end
|
177
|
+
|
178
|
+
=begin
|
179
|
+
--- NodeList#+(nodes)
|
180
|
+
|
181
|
+
return the newly created concatenated NodeList.
|
182
|
+
=end
|
183
|
+
def +(nodes)
|
184
|
+
if nodes.nil?
|
185
|
+
NodeList.new(@nodes)
|
186
|
+
elsif nodes.is_a?(Array)
|
187
|
+
NodeList.new(@nodes + nodes)
|
188
|
+
elsif nodes.is_a?(NodeList)
|
189
|
+
NodeList.new(@nodes + nodes.to_a)
|
190
|
+
elsif nodes.is_a?(Node)
|
191
|
+
NodeList.new(@nodes + [nodes])
|
192
|
+
else
|
193
|
+
raise "parameter error"
|
194
|
+
end
|
195
|
+
end
|
196
|
+
|
197
|
+
=begin
|
198
|
+
--- NodeList#<<(nodes)
|
199
|
+
|
200
|
+
appends nodes to the NodeList.
|
201
|
+
=end
|
202
|
+
## modified by Masaki Fukushima
|
203
|
+
def <<(nodes)
|
204
|
+
if nodes.nil?
|
205
|
+
## no change
|
206
|
+
elsif nodes.is_a?(Array)
|
207
|
+
@nodes.concat(nodes)
|
208
|
+
elsif nodes.is_a?(NodeList)
|
209
|
+
@nodes.concat(nodes.to_a)
|
210
|
+
elsif nodes.is_a?(Node)
|
211
|
+
@nodes << nodes
|
212
|
+
else
|
213
|
+
raise "parameter error"
|
214
|
+
end
|
215
|
+
self
|
216
|
+
end
|
217
|
+
|
218
|
+
## get nodeValues by names
|
219
|
+
## names ::= name ('|' name)*
|
220
|
+
def _getValues(names)
|
221
|
+
ret = []
|
222
|
+
names.split('|').each do |name|
|
223
|
+
if !@nodes[name].nil?
|
224
|
+
ret.push(@nodes[name].nodeValue)
|
225
|
+
end
|
226
|
+
end
|
227
|
+
ret
|
228
|
+
end
|
229
|
+
end
|
230
|
+
end
|
231
|
+
end
|
@@ -0,0 +1,86 @@
|
|
1
|
+
## -*- Ruby -*-
|
2
|
+
## XML::DOM
|
3
|
+
## 1998-2001 by yoshidam
|
4
|
+
##
|
5
|
+
|
6
|
+
require 'xml/dom2/node'
|
7
|
+
|
8
|
+
module XML
|
9
|
+
module DOM
|
10
|
+
|
11
|
+
=begin
|
12
|
+
== Class XML::DOM::Notation
|
13
|
+
|
14
|
+
=== superclass
|
15
|
+
Node
|
16
|
+
=end
|
17
|
+
class Notation<Node
|
18
|
+
=begin
|
19
|
+
=== Class Methods
|
20
|
+
|
21
|
+
--- Notation.new(name, pubid, sysid)
|
22
|
+
|
23
|
+
creates a new Notation.
|
24
|
+
=end
|
25
|
+
def initialize(name, pubid, sysid)
|
26
|
+
super()
|
27
|
+
@name = name.freeze
|
28
|
+
@pubid = pubid.freeze
|
29
|
+
@sysid = sysid.freeze
|
30
|
+
end
|
31
|
+
|
32
|
+
=begin
|
33
|
+
=== Methods
|
34
|
+
|
35
|
+
--- Notation#nodeType
|
36
|
+
|
37
|
+
[DOM]
|
38
|
+
returns the nodeType.
|
39
|
+
=end
|
40
|
+
## [DOM]
|
41
|
+
def nodeType
|
42
|
+
NOTATION_NODE
|
43
|
+
end
|
44
|
+
|
45
|
+
=begin
|
46
|
+
--- Notation#nodeName
|
47
|
+
|
48
|
+
[DOM]
|
49
|
+
returns the nodeName.
|
50
|
+
=end
|
51
|
+
## [DOM]
|
52
|
+
def nodeName
|
53
|
+
@name
|
54
|
+
end
|
55
|
+
|
56
|
+
=begin
|
57
|
+
--- Notation#publicId
|
58
|
+
|
59
|
+
returns the publicId of the Notation.
|
60
|
+
=end
|
61
|
+
def publicId
|
62
|
+
@pubid
|
63
|
+
end
|
64
|
+
|
65
|
+
=begin
|
66
|
+
--- Notation#systemId
|
67
|
+
|
68
|
+
returns the systemId of the Notation.
|
69
|
+
=end
|
70
|
+
def systemId
|
71
|
+
@sysid
|
72
|
+
end
|
73
|
+
|
74
|
+
=begin
|
75
|
+
--- Notation#cloneNode(deep = true)
|
76
|
+
|
77
|
+
[DOM]
|
78
|
+
returns the copy of the Notation.
|
79
|
+
=end
|
80
|
+
## [DOM]
|
81
|
+
def cloneNode(deep = true)
|
82
|
+
super(deep, @name, @pubid, @sysid)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
end
|
86
|
+
end
|
@@ -0,0 +1,155 @@
|
|
1
|
+
## -*- Ruby -*-
|
2
|
+
## XML::DOM
|
3
|
+
## 1998-2001 by yoshidam
|
4
|
+
##
|
5
|
+
|
6
|
+
require 'xml/dom2/node'
|
7
|
+
|
8
|
+
module XML
|
9
|
+
module DOM
|
10
|
+
|
11
|
+
=begin
|
12
|
+
== Class XML::DOM::ProcessingInstruction
|
13
|
+
|
14
|
+
=== superclass
|
15
|
+
Node
|
16
|
+
|
17
|
+
=end
|
18
|
+
class ProcessingInstruction<Node
|
19
|
+
|
20
|
+
=begin
|
21
|
+
=== Class Methods
|
22
|
+
|
23
|
+
--- ProcessingInstruction.new(target = nil, data = nil)
|
24
|
+
|
25
|
+
creates a new ProcessingInstruction.
|
26
|
+
=end
|
27
|
+
## new(target, data)
|
28
|
+
## target: String
|
29
|
+
## data: String
|
30
|
+
def initialize(target = nil, data = nil)
|
31
|
+
super()
|
32
|
+
raise "parameter error" if !data
|
33
|
+
@target = target.freeze
|
34
|
+
@data = data.freeze
|
35
|
+
@value = target.dup
|
36
|
+
@value << " #{data}" if data != ""
|
37
|
+
@value.freeze
|
38
|
+
end
|
39
|
+
|
40
|
+
=begin
|
41
|
+
=== Methods
|
42
|
+
|
43
|
+
--- ProcessingInstruction#nodeType
|
44
|
+
|
45
|
+
[DOM]
|
46
|
+
returns the nodeType.
|
47
|
+
=end
|
48
|
+
## [DOM]
|
49
|
+
def nodeType
|
50
|
+
PROCESSING_INSTRUCTION_NODE
|
51
|
+
end
|
52
|
+
|
53
|
+
=begin
|
54
|
+
--- ProcessingInstruction#nodeName
|
55
|
+
|
56
|
+
[DOM]
|
57
|
+
returns the nodeName.
|
58
|
+
=end
|
59
|
+
## [DOM]
|
60
|
+
def nodeName
|
61
|
+
"#proccessing-instruction"
|
62
|
+
end
|
63
|
+
|
64
|
+
=begin
|
65
|
+
--- ProcessingInstruction#target
|
66
|
+
|
67
|
+
[DOM]
|
68
|
+
returns the target of the ProcessingInstruction.
|
69
|
+
=end
|
70
|
+
## [DOM]
|
71
|
+
def target
|
72
|
+
@target
|
73
|
+
end
|
74
|
+
|
75
|
+
def target=(p)
|
76
|
+
@target = p.freeze
|
77
|
+
@value = @target.dup
|
78
|
+
@value << " #{@data}" if @data != ""
|
79
|
+
@value.freeze
|
80
|
+
end
|
81
|
+
|
82
|
+
=begin
|
83
|
+
--- ProcessingInstruction#data
|
84
|
+
|
85
|
+
[DOM]
|
86
|
+
return the content of the ProcessingInstruction.
|
87
|
+
=end
|
88
|
+
## [DOM]
|
89
|
+
def data
|
90
|
+
@data
|
91
|
+
end
|
92
|
+
|
93
|
+
=begin
|
94
|
+
--- ProcessingInstruction#data=(p)
|
95
|
+
|
96
|
+
[DOM]
|
97
|
+
sets p to the content of the ProcessingInstruction.
|
98
|
+
=end
|
99
|
+
## [DOM]
|
100
|
+
def data=(p)
|
101
|
+
@data = p.freeze
|
102
|
+
@value = @target.dup
|
103
|
+
@value << " #{@data}" if @data != ""
|
104
|
+
@value.freeze
|
105
|
+
end
|
106
|
+
|
107
|
+
=begin
|
108
|
+
--- ProcessingInstruction#nodeValue
|
109
|
+
|
110
|
+
[DOM]
|
111
|
+
return nodevalue.
|
112
|
+
|
113
|
+
=end
|
114
|
+
## [DOM]
|
115
|
+
def nodeValue
|
116
|
+
@value
|
117
|
+
end
|
118
|
+
|
119
|
+
## inhibit changing value without target= or data=
|
120
|
+
undef nodeValue=
|
121
|
+
|
122
|
+
=begin
|
123
|
+
--- ProcessingInstruction#to_s
|
124
|
+
|
125
|
+
returns the string representation of the ProcessingInstruction.
|
126
|
+
=end
|
127
|
+
def to_s
|
128
|
+
ret = "<?#{@value}?>"
|
129
|
+
ret << "\n" if parentNode.nodeType == DOCUMENT_NODE
|
130
|
+
ret
|
131
|
+
end
|
132
|
+
|
133
|
+
=begin
|
134
|
+
--- ProcessingInstruction#dump(depth = 0)
|
135
|
+
|
136
|
+
dumps the ProcessingInstruction.
|
137
|
+
=end
|
138
|
+
def dump(depth = 0)
|
139
|
+
print ' ' * depth * 2
|
140
|
+
print "<?#{@value.inspect}?>\n"
|
141
|
+
end
|
142
|
+
|
143
|
+
=begin
|
144
|
+
--- ProcessingInstruction#cloneNode(deep = true)
|
145
|
+
|
146
|
+
[DOM]
|
147
|
+
returns the copy of the ProcessingInstruction.
|
148
|
+
=end
|
149
|
+
## [DOM]
|
150
|
+
def cloneNode(deep = true)
|
151
|
+
super(deep, @target, @data)
|
152
|
+
end
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|