vcdom 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,9 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module VCDOM
4
+ module MiniDOM
5
+ class MiniDOMStandardError < StandardError
6
+
7
+ end
8
+ end
9
+ end
@@ -0,0 +1,51 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require "vcdom/minidom/mod_parent_node"
4
+
5
+ module VCDOM
6
+ module MiniDOM
7
+ module ModChildNode
8
+
9
+ # Attr, Document, DocumentFragment, Entity, Notation 以外のクラスに Mixed-in される
10
+
11
+ include ModParentNode::ParentNodeManageable
12
+
13
+ # parentNode of type Node, readonly
14
+ # The parent of this node.
15
+ # All nodes, except Attr, Document, DocumentFragment, Entity, and Notation may
16
+ # have a parent.
17
+ # However, if a node has just been created and not yet added to the tree,
18
+ # or if it has been removed from the tree, this is null.
19
+ def parent_node
20
+ return @parent_node
21
+ end
22
+
23
+ # previousSibling of type Node, readonly
24
+ # The node immediately preceding this node.
25
+ # If there is no such node, this returns null.
26
+ def previous_sibling
27
+ if ! @parent_node.nil? then
28
+ if idx = @parent_node.get_index_of( self ) then
29
+ return @parent_node.child_nodes.item( idx - 1 )
30
+ end
31
+ end
32
+ return nil
33
+ end
34
+ # nextSibling of type Node, readonly
35
+ # The node immediately following this node. If there is no such node, this returns null.
36
+ def next_sibling
37
+ if ! @parent_node.nil? then
38
+ if idx = @parent_node.get_index_of( self ) then
39
+ return @parent_node.child_nodes.item( idx + 1 )
40
+ end
41
+ end
42
+ return nil
43
+ end
44
+
45
+ def init_mod_child_node()
46
+ @parent_node = nil
47
+ end
48
+
49
+ end
50
+ end
51
+ end
@@ -0,0 +1,49 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require "vcdom/minidom/node_list"
4
+
5
+ module VCDOM
6
+ module MiniDOM
7
+ module ModElementsGetter
8
+
9
+ # Document, Element に Mixed-in
10
+
11
+ def get_elements_by_tagname( tagname )
12
+ list = []
13
+ _add_matched_descendant_elems_to_list( self, list, tagname )
14
+ return NodeList.new( list )
15
+ end
16
+
17
+ def get_elements_by_tagname_ns( namespace_uri, local_name )
18
+ list = []
19
+ _add_matched_descendant_elems_to_list_ns( self, list, namespace_uri, local_name )
20
+ return NodeList.new( list )
21
+ end
22
+
23
+ private
24
+ def _add_matched_descendant_elems_to_list( elem, list, tagname )
25
+ elem.child_nodes.each do |item|
26
+ if item.node_type == Node::ELEMENT_NODE and
27
+ ( tagname == '*' or item.tagname == tagname ) then
28
+ list << item
29
+ end
30
+ _add_matched_descendant_elems_to_list( item, list, tagname )
31
+ end
32
+ end
33
+ def _add_matched_descendant_elems_to_list_ns( elem, list, namespace_uri, local_name )
34
+ elem.child_nodes.each do |item|
35
+ if item.node_type == Node::ELEMENT_NODE then
36
+ if namespace_uri == '*' or ( namespace_uri.nil? and item.namespace_uri.nil? ) or
37
+ namespace_uri == item.namespace_uri then
38
+ if local_name == '*' or local_name == item.local_name then
39
+ list << item
40
+ end
41
+ end
42
+ end
43
+ _add_matched_descendant_elems_to_list_ns( item, list, namespace_uri, local_name )
44
+ end
45
+ end
46
+
47
+ end
48
+ end
49
+ end
@@ -0,0 +1,152 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ module VCDOM
4
+ module MiniDOM
5
+ module ModNamespaceURIManageable
6
+
7
+ # namespaceURI of type DOMString, readonly, introduced in DOM Level 2
8
+ # The namespace URI of this node, or null if it is unspecified (see XML Namespaces).
9
+ # This is not a computed value that is the result of a namespace lookup based on
10
+ # an examination of the namespace declarations in scope.
11
+ # It is merely the namespace URI given at creation time.
12
+ # For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and
13
+ # nodes created with a DOM Level 1 method, such as Document.createElement(),
14
+ # this is always null.
15
+ #
16
+ # Note: Per the Namespaces in XML Specification [XML Namespaces] an attribute
17
+ # does not inherit its namespace from the element it is attached to.
18
+ # If an attribute is not explicitly given a namespace, it simply has
19
+ # no namespace.
20
+ def namespace_uri
21
+ return @namespace_uri
22
+ end
23
+
24
+ # localName of type DOMString, readonly, introduced in DOM Level 2
25
+ # Returns the local part of the qualified name of this node.
26
+ # For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes
27
+ # created with a DOM Level 1 method, such as Document.createElement(),
28
+ # this is always null.
29
+ def local_name
30
+ qname_arr = self.node_name.split(/:/u)
31
+ return qname_arr[-1]
32
+ end
33
+
34
+ # prefix of type DOMString, introduced in DOM Level 2
35
+ # The namespace prefix of this node, or null if it is unspecified.
36
+ # #=> このノードの名前空間接頭辞, または null (指定されていない場合) です.
37
+ # When it is defined to be null, setting it has no effect, including if the node is read-only.
38
+ # #=> null と明示されている場合, およびノードが読み取り専用の場合は, 値の代入は何の効果もありません.
39
+ # Note that setting this attribute, when permitted, changes the nodeName attribute,
40
+ # which holds the qualified name, as well as the tagName and name attributes of the Element
41
+ # and Attr interfaces, when applicable.
42
+ # #=> (代入可能な場合に) 値の代入を行うと, nodeName 属性 (qualified name を保持している) が変化します.
43
+ # #=> Element インターフェイスの tagName 属性や Attr インターフェイスの name 属性も同様です. (それらに応用可能な場合)
44
+ # Setting the prefix to null makes it unspecified, setting it to an empty string is implementation dependent.
45
+ # Note also that changing the prefix of an attribute that is known to have a default value,
46
+ # does not make a new attribute with the default value and the original prefix appear,
47
+ # since the namespaceURI and localName do not change.
48
+ # For nodes of any type other than ELEMENT_NODE and ATTRIBUTE_NODE and nodes created
49
+ # with a DOM Level 1 method, such as createElement from the Document interface, this is always null.
50
+ #
51
+ # Exceptions on setting
52
+ # DOMException
53
+ # INVALID_CHARACTER_ERR:
54
+ # Raised if the specified prefix contains an illegal character according to the XML version
55
+ # in use specified in the Document.xmlVersion attribute.
56
+ # NO_MODIFICATION_ALLOWED_ERR:
57
+ # Raised if this node is readonly.
58
+ # NAMESPACE_ERR:
59
+ # Raised if the specified prefix is malformed per the Namespaces in XML specification,
60
+ # if the namespaceURI of this node is null, if the specified prefix is "xml" and
61
+ # the namespaceURI of this node is different from "http://www.w3.org/XML/1998/namespace",
62
+ # if this node is an attribute and the specified prefix is "xmlns" and
63
+ # the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/",
64
+ # or if this node is an attribute and the qualifiedName of this node is "xmlns" [XML Namespaces].
65
+ def prefix
66
+ qname_arr = self.node_name.split(/:/u)
67
+ return qname_arr[-2]
68
+ end
69
+ def prefix=( value )
70
+ if self.is_readonly then
71
+ raise DOMException.new( DOMException::NO_MODIFICATION_ALLOWED_ERR,
72
+ 'This node is readonly.' )
73
+ end
74
+ unless value.nil? or value.is_a? String then
75
+ begin
76
+ value = value.to_str()
77
+ rescue
78
+ raise TypeError.new( 'The argument value must be String object or nil.' )
79
+ end
80
+ end
81
+ if value.nil? or value.length == 0 then
82
+ self.node_name = self.local_name
83
+ end
84
+ if XMLRegExp::NCNAME =~ value then
85
+ if self.namespace_uri.nil? then
86
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
87
+ 'The namespace URI of this node is null, so an prefix can\'t be set.' )
88
+ end
89
+ if value == "xml" and self.namespace_uri != "http://www.w3.org/XML/1998/namespace" then
90
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
91
+ 'The specified prefix is "xml" and the namespace URI of this node is different from "http://www.w3.org/XML/1998/namespace"' )
92
+ end
93
+ if self.node_type == Node::ATTRIBUTE_NODE then
94
+ if value == 'xmlns' and self.namespace_uri != "http://www.w3.org/2000/xmlns/" then
95
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
96
+ 'The specified prefix is "xmlns" and the namespaceURI of this node is different from "http://www.w3.org/2000/xmlns/".' )
97
+ end
98
+ if self.node_name == 'xmlns' then
99
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
100
+ 'The qualifiedName of this node is "xmlns".' )
101
+ end
102
+ end
103
+ self.tagname = value + ':' + self.local_name
104
+ else
105
+ raise DOMException.new( DOMException::INVALID_CHARACTER_ERR,
106
+ 'The specified prefix "' + value + '" contains an illegal character.' )
107
+ end
108
+ end
109
+
110
+ def init_mod_namespaceuri_manageable( namespace_uri, qualified_name )
111
+ # namespace_uri が空文字列であるならば, nil として扱う
112
+ @namespace_uri = ( namespace_uri == '' ? nil : namespace_uri )
113
+ if /\A([^:]+)(?::([^:]+))?\Z/u =~ qualified_name then
114
+ name_prefix = ( $2.nil? ? nil : $1 )
115
+ else
116
+ # the qualified name is malformed
117
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
118
+ 'The qualified name "' + qualified_name + '" is malformed.' )
119
+ end
120
+ if ! name_prefix.nil? then
121
+ if @namespace_uri.nil? then
122
+ # the qualified name has a prefix and the namespace URI is null
123
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
124
+ 'The qualified name "' + qualified_name + '" has a prefix, but the namespace URI is null.' )
125
+ end
126
+ if name_prefix == 'xml' and @namespace_uri != "http://www.w3.org/XML/1998/namespace" then
127
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
128
+ 'The qualified name has a prefix "xml", but the namespace URI is different from "http://www.w3.org/XML/1998/namespace".' )
129
+ end
130
+ if name_prefix == 'xmlns' and @namespace_uri != "http://www.w3.org/2000/xmlns/" then
131
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
132
+ 'The qualified name has a prefix "xmlns", but the namespace URI is different from "http://www.w3.org/2000/xmlns/".' )
133
+ end
134
+ if name_prefix != 'xmlns' and @namespace_uri == "http://www.w3.org/2000/xmlns/" then
135
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
136
+ 'The namespace URI is "http://www.w3.org/2000/xmlns/", but the prefix of the qualified name is not "xmlns".' )
137
+ end
138
+ else
139
+ if qualified_name == 'xmlns' and @namespace_uri != "http://www.w3.org/2000/xmlns/" then
140
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
141
+ 'The qualified name is "xmlns", but the namespace URI is different from "http://www.w3.org/2000/xmlns/".' )
142
+ end
143
+ if qualified_name != 'xmlns' and @namespace_uri == "http://www.w3.org/2000/xmlns/" then
144
+ raise DOMException.new( DOMException::NAMESPACE_ERR,
145
+ 'The namespace URI is "http://www.w3.org/2000/xmlns/", but the qualified name is not "xmlns".' )
146
+ end
147
+ end
148
+ end
149
+
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,307 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+ require "vcdom/minidom/node_list"
4
+
5
+ module VCDOM
6
+ module MiniDOM
7
+ module ModParentNode
8
+
9
+ # Document, DocumentFragment, EntityReference, Element, Attr, Entity に
10
+ # Mixed-in される
11
+
12
+ module ParentNodeManageable
13
+ protected
14
+ def parent_node=( pn )
15
+ @parent_node = pn
16
+ end
17
+ def get_index_of( child_node )
18
+ @child_nodes.each_index do |index|
19
+ if @child_nodes[index].equal? child_node then
20
+ return index
21
+ end
22
+ end
23
+ return nil
24
+ end
25
+ end
26
+
27
+ include ParentNodeManageable
28
+
29
+ # childNodes of type NodeList, readonly
30
+ # A NodeList that contains all children of this node. If there are no children, this is a NodeList containing no nodes.
31
+ def child_nodes; return @child_nodes_wrapper end
32
+
33
+ # firstChild of type Node, readonly
34
+ # The first child of this node. If there is no such node, this returns null.
35
+ def first_child; return @child_nodes[0] end
36
+
37
+ # lastChild of type Node, readonly
38
+ # The last child of this node. If there is no such node, this returns null.
39
+ def last_child; return @child_nodes[-1] end
40
+
41
+ # hasChildNodes
42
+ #
43
+ # Returns whether this node has any children.
44
+ #
45
+ # Return Value
46
+ # boolean
47
+ # Returns true if this node has any children, false otherwise.
48
+ # No Parameters
49
+ # No Exceptions
50
+ def has_child_nodes()
51
+ return ( @child_nodes.length > 0 ) ? true : false
52
+ end
53
+
54
+ # textContent of type DOMString, introduced in DOM Level 3
55
+ #
56
+ # This attribute returns the text content of this node and its descendants.
57
+ # When it is defined to be null, setting it has no effect.
58
+ # On setting, any possible children this node may have are removed and,
59
+ # if it the new string is not empty or null, replaced by a single Text node
60
+ # containing the string this attribute is set to.
61
+ # On getting, no serialization is performed, the returned string does not
62
+ # contain any markup. No whitespace normalization is performed and the
63
+ # returned string does not contain the white spaces in element content
64
+ # (see the attribute Text.isElementContentWhitespace).
65
+ # Similarly, on setting, no parsing is performed either, the input string
66
+ # is taken as pure textual content.
67
+ #
68
+ # The string returned is made of the text content of this node depending on
69
+ # its type, as defined below:
70
+ #
71
+ # Node type Content
72
+ # ---------------------------------------------------
73
+ # ELEMENT_NODE, ATTRIBUTE_NODE, concatenation of the textContent attribute value
74
+ # ENTITY_NODE, of every child node, excluding COMMENT_NODE and
75
+ # ENTITY_REFERENCE_NODE, PROCESSING_INSTRUCTION_NODE nodes. This is the
76
+ # DOCUMENT_FRAGMENT_NODE empty string if the node has no children.
77
+ #
78
+ # Exceptions on setting
79
+ # DOMException
80
+ # NO_MODIFICATION_ALLOWED_ERR: Raised when the node is readonly.
81
+ # Exceptions on retrieval
82
+ # DOMException
83
+ # DOMSTRING_SIZE_ERR: Raised when it would return more characters
84
+ # than fit in a DOMString variable on the implementation platform.
85
+ #
86
+ # Document node でオーバーライド
87
+ def text_content
88
+ value = String.new()
89
+ @child_nodes.each do |node|
90
+ case node.node_type
91
+ when Node::COMMENT_NODE, Node::PROCESSING_INSTRUCTION_NODE then
92
+ # do nothing
93
+ else
94
+ value << node.text_content
95
+ end
96
+ end
97
+ return value
98
+ end
99
+ def text_content=( value )
100
+ if self.is_readonly then
101
+ raise DOMException.new( NO_MODIFICATION_ALLOWED_ERR, 'This node is readonly.' )
102
+ end
103
+ while self.has_child_nodes do
104
+ self.remove_child( self.first_child )
105
+ end
106
+ unless value.nil? or value.length == 0 then
107
+ self.append_child( self.owner_document.create_text_node( value ) )
108
+ end
109
+ end
110
+
111
+ # appendChild modified in DOM Level 3
112
+ #
113
+ # Adds the node newChild to the end of the list of children of this node.
114
+ # If the newChild is already in the tree, it is first removed.
115
+ #
116
+ # Parameters
117
+ # newChild of type Node
118
+ # The node to add.
119
+ # If it is a DocumentFragment object, the entire contents of the document fragment are moved
120
+ # into the child list of this node
121
+ # Return Value
122
+ # Node
123
+ # The node added.
124
+ # Exceptions
125
+ # DOMException
126
+ # HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not
127
+ # allow children of the type of the newChild node, or if the
128
+ # node to append is one of this node's ancestors or this node
129
+ # itself, or if this node is of type Document and the DOM
130
+ # application attempts to append a second DocumentType or
131
+ # Element node.
132
+ # #=> newNode がこのノードの子になれない nodeType である場合や, newNode がこのノードの先祖である場合や自分自身
133
+ # #=> である場合, また, もしこのノードのタイプが Document で 2 つ目の DocumentType や Element を追加しようとした場合など
134
+ # #=> にこの例外が発生する.
135
+ # WRONG_DOCUMENT_ERR: Raised if newChild was created from a different
136
+ # document than the one that created this node.
137
+ # (DOMImplementation より
138
+ # WRONG_DOCUMENT_ERR: Raised if doctype has already been used with a different
139
+ # document or was created from a different implementation.
140
+ # NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the
141
+ # previous parent of the node being inserted is readonly.
142
+ # NOT_SUPPORTED_ERR: if the newChild node is a child of the Document node, this exception might
143
+ # be raised if the DOM implementation doesn't support the removal of the DocumentType
144
+ # child or Element child.
145
+ def append_child( new_child )
146
+ new_child_list = []
147
+ if new_child.node_type == Node::DOCUMENT_FRAGMENT_NODE then
148
+ while new_child.has_child_nodes do
149
+ new_child_list << new_child.remove_child( new_child.first_child )
150
+ end
151
+ else
152
+ new_child_list << new_child
153
+ end
154
+ new_child_list.each do |nc|
155
+ # Hierarchy request err のチェック
156
+ begin
157
+ check_hierarchy( nc )
158
+ rescue => err
159
+ raise err
160
+ end
161
+ # Wrong document err のチェック
162
+ cdoc = ( self.owner_document or self )
163
+ if nc.node_type != Node::DOCUMENT_TYPE_NODE then
164
+ if nc.owner_document != cdoc then
165
+ raise DOMException.new( DOMException::WRONG_DOCUMENT_ERR,
166
+ 'The new child was created from a different document than the one that created this node.' )
167
+ end
168
+ end
169
+ end
170
+ new_child_list.each do |nc|
171
+ # 親が居る場合, まず取り除く
172
+ if ! nc.parent_node.nil? then
173
+ nc.parent_node.remove_child( nc )
174
+ end
175
+ @child_nodes << nc
176
+ nc.parent_node = self
177
+ end
178
+ #$stdout << "ModParentNode#append_child: " << new_child << "\n"
179
+ #$stdout << "ModParentNode#append_child: " << new_child.node_name << "\n"
180
+ return new_child
181
+ end
182
+
183
+ # insertBefore modified in DOM Level 3
184
+ #
185
+ # Inserts the node newChild before the existing child node refChild. If refChild is null,
186
+ # insert newChild at the end of the list of children.
187
+ # If newChild is a DocumentFragment object, all of its children are inserted, in the same
188
+ # order, before refChild. If the newChild is already in the tree, it is first removed.
189
+ #
190
+ # Note: Inserting a node before itself is implementation dependent.
191
+ #
192
+ # Parameters
193
+ # newChild of type Node
194
+ # The node to insert.
195
+ # refChild of type Node
196
+ # The reference node, i.e., the node before which the new node must be inserted.
197
+ # Return Value
198
+ # Node
199
+ # The node being inserted.
200
+ # Exceptions
201
+ # DOMException
202
+ # HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children
203
+ # of the type of the newChild node, or if the node to insert is one of this node's
204
+ # ancestors or this node itself, or if this node is of type Document and the DOM
205
+ # application attempts to insert a second DocumentType or Element node.
206
+ # WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the
207
+ # one that created this node.
208
+ # NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly or if the parent of the node
209
+ # being inserted is readonly.
210
+ # NOT_FOUND_ERR: Raised if refChild is not a child of this node.
211
+ # NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the
212
+ # DOM implementation doesn't support the insertion of a DocumentType or Element node.
213
+ def insert_before( new_child, ref_child )
214
+ # aRefChild の index 取得. なければ例外発生
215
+ ( idx = @child_nodes.index( ref_child ) )\
216
+ or raise DOMException.new( DOMException::NOT_FOUND_ERR, "NOT_FOUND_ERR" )
217
+ # 追加処理
218
+ return add_child_at( idx, new_child )
219
+ end
220
+
221
+ # removeChild modified in DOM Level 3
222
+ #
223
+ # Removes the child node indicated by oldChild from the list of children, and returns it.
224
+ #
225
+ # Parameters
226
+ # oldChild of type Node
227
+ # The node being removed.
228
+ # Return Value
229
+ # Node
230
+ # The node removed.
231
+ # Exceptions
232
+ # DOMException
233
+ # NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
234
+ # NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
235
+ # NOT_SUPPORTED_ERR: if this node is of type Document, this exception
236
+ # might be raised if the DOM implementation doesn't support
237
+ # the removal of the DocumentType child or the Element child.
238
+ def remove_child( old_child )
239
+ # aOldChild の index を取得. 子ノードに含まれなければ例外発生
240
+ ( idx = get_index_of( old_child ) ) or
241
+ raise DOMException.new( DOMException::NOT_FOUND_ERR, "The old child is not a child of this node." )
242
+ # 削除
243
+ @child_nodes.delete_at( idx )
244
+ old_child.parent_node = nil
245
+ return old_child
246
+ end
247
+
248
+ # replaceChild modified in DOM Level 3
249
+ #
250
+ # Replaces the child node oldChild with newChild in the list of children, and returns the oldChild node.
251
+ # #=> 子ノードのうち、oldChild を newChild で置き換え、oldChild を返す.
252
+ # If newChild is a DocumentFragment object, oldChild is replaced by all of the DocumentFragment children,
253
+ # which are inserted in the same order.
254
+ # #=> もし newChild が DocumentFragment オブジェクトならば, oldChild は newChild の全ての子をそのままの順で置き換えられる.
255
+ # If the newChild is already in the tree, it is first removed.
256
+ # #=> もし newChild が既に DOM 木の中に存在するならば, まず最初に取り除かれる.
257
+ #
258
+ # Note: Replacing a node with itself is implementation dependent.
259
+ # #=> Note: 自分自身を自分自身で置き換えようとしたときの動作は, 実装に依存する.
260
+ #
261
+ # Parameters
262
+ # newChild of type Node
263
+ # The new node to put in the child list.
264
+ # oldChild of type Node
265
+ # The node being replaced in the list.
266
+ # Return Value
267
+ # Node
268
+ # The node replaced.
269
+ # Exceptions
270
+ # DOMException
271
+ # HIERARCHY_REQUEST_ERR: Raised if this node is of a type that does not allow children of the type
272
+ # of the newChild node, or if the node to put in is one of this node's ancestors or this
273
+ # node itself, or if this node is of type Document and the result of the replacement
274
+ # operation would add a second DocumentType or Element on the Document node.
275
+ # WRONG_DOCUMENT_ERR: Raised if newChild was created from a different document than the one that
276
+ # created this node.
277
+ # NO_MODIFICATION_ALLOWED_ERR: Raised if this node or the parent of the new node is readonly.
278
+ # NOT_FOUND_ERR: Raised if oldChild is not a child of this node.
279
+ # NOT_SUPPORTED_ERR: if this node is of type Document, this exception might be raised if the DOM
280
+ # implementation doesn't support the replacement of the DocumentType child or Element child.
281
+ def replace_child( new_child, old_child )
282
+ # 未実装
283
+ end
284
+
285
+ private
286
+ # サブクラスでオーバーライドしなければならない
287
+ def check_hierarchy( new_child, is_overrided = false )
288
+ raise "The internal error in VCDOM::MiniDOM is occured." unless is_overrided
289
+ # new_child が自分の先祖でないかどうかのチェック
290
+ elem = self
291
+ while ! elem.nil? do
292
+ if elem.equal? new_child then
293
+ raise DOMException.new( DOMException::HIERARCHY_REQUEST_ERR,
294
+ 'The node to append is one of this node\'s ancestors or this node itself.' )
295
+ end
296
+ elem = elem.parent_node
297
+ end
298
+ end
299
+
300
+ def init_mod_parent_node()
301
+ @child_nodes = []
302
+ @child_nodes_wrapper = NodeList.new( @child_nodes )
303
+ end
304
+
305
+ end
306
+ end
307
+ end