nokogiri 1.5.7.rc1-java → 1.5.7.rc2-java

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of nokogiri might be problematic. Click here for more details.

@@ -1,9 +1,23 @@
1
- == 1.5.7 / unreleased
1
+ == 1.5.x
2
+
3
+ === 1.5.7 / unreleased
2
4
 
3
5
  * Bugfixes
6
+ * SAX::Parser.parse_io throw an error when used with lower case encoding. #828
4
7
  * (JRuby) Java Nokogiri is finally green (passes all tests) under 1.8 and 1.9 mode. High five everyone. #798, #705
8
+ * (JRuby) Nokogiri::XML::Reader broken (as a pull parser) on jruby - reads the whole XML document. #831
9
+ * (JRuby) JRuby hangs parsing "&". #837
10
+ * (JRuby) JRuby NPE parsing an invalid XML instruction. #838
11
+ * (JRuby) Node#content= incompatibility. #839
12
+ * (JRuby) to_xhtml doesn't print the last slash for self-closing tags in JRuby. #834
13
+ * (JRuby) Adding an EntityReference after a Text node mangles the entity in JRuby. #835
14
+ * (JRuby) JRuby version inconsistency: nil for empty attributes. #818
15
+ * CSS queries for classes (e.g., ".foo") now treat all whitespace identically. #854
16
+ * Namespace behavior cleaned up and made consistent between JRuby and MRI. #846, #801 (Thanks, Michael Klein!)
17
+ * (MRI) SAX parser handles empty processing instructions. #845
18
+
5
19
 
6
- == 1.5.6 / 2012年12月19日
20
+ === 1.5.6 / 2012年12月19日
7
21
 
8
22
  * Features
9
23
 
@@ -41,7 +55,7 @@
41
55
  * (JRuby) builder requires textwrappers for valid utf8 in jruby, not in mri. #784
42
56
 
43
57
 
44
- == 1.5.5 / 2012年6月24日
58
+ === 1.5.5 / 2012年6月24日
45
59
 
46
60
  * Features
47
61
 
@@ -63,7 +77,7 @@
63
77
  * JRuby の Entity 解決は C version の Nokogiri と同じ結果にならないといけない。#704, #647, #703
64
78
 
65
79
 
66
- == 1.5.4 / 2012年6月12日
80
+ === 1.5.4 / 2012年6月12日
67
81
 
68
82
  * Features
69
83
 
@@ -87,7 +101,7 @@
87
101
  ここに、自分ならではの二重否定のジョークをうめこむとなおよし。
88
102
 
89
103
 
90
- == 1.5.3 / 2012年6月1日
104
+ === 1.5.3 / 2012年6月1日
91
105
 
92
106
  * Features
93
107
 
@@ -115,12 +129,12 @@
115
129
  * (JRuby) Concurrency issue in XPath parsing. #682
116
130
 
117
131
 
118
- == 1.5.2 / 2012-03-09
132
+ === 1.5.2 / 2012-03-09
119
133
 
120
134
  Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631, #632.
121
135
 
122
136
 
123
- == 1.5.1 / 2012年3月9日
137
+ === 1.5.1 / 2012年3月9日
124
138
 
125
139
  * 新機能
126
140
 
@@ -165,7 +179,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
165
179
  * Node#set is a private method (JRuby). #564 (thanks, Nick Sieger!)
166
180
  * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
167
181
 
168
- == 1.5.0 / 2011年7月1日
182
+ === 1.5.0 / 2011年7月1日
169
183
 
170
184
  * 註
171
185
 
@@ -185,7 +199,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
185
199
  * <meta charset="..."> を認識するようになった.
186
200
 
187
201
 
188
- == 1.5.0 beta3 2010年12月2日
202
+ === 1.5.0 beta3 2010年12月2日
189
203
 
190
204
  * 註
191
205
 
@@ -196,13 +210,13 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
196
210
 
197
211
  * Node#inner_textはnilを返さなくなった. (JRuby) #264
198
212
 
199
- == 1.5.0 beta2 2010年7月30日
213
+ === 1.5.0 beta2 2010年7月30日
200
214
 
201
215
  * 註
202
216
 
203
217
  * 1.4.3からの変更点を参照
204
218
 
205
- == 1.5.0 beta1 2010年5月22日
219
+ === 1.5.0 beta1 2010年5月22日
206
220
 
207
221
  * 註
208
222
 
@@ -214,6 +228,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
214
228
  * LibXML 2.6.16および古いバージョンは非推奨. インストールできない.
215
229
  * FFIサポートは削除された.
216
230
 
231
+
232
+ == 1.4.x
233
+
217
234
  === 1.4.7 / 2011年7月1日
218
235
 
219
236
  * バグの修正
@@ -423,6 +440,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
423
440
 
424
441
  * Hpricot用の互換性レイヤーを削除
425
442
 
443
+
444
+ == 1.3.x
445
+
426
446
  === 1.3.3 / 2009年7月26日
427
447
 
428
448
  * 新しい機能
@@ -529,6 +549,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
529
549
  * Node#before/after/inner_html=で値なしのHTML属性が受け入れられなかった問題を
530
550
  修正 (GH#35)
531
551
 
552
+
553
+ == 1.2.x
554
+
532
555
  === 1.2.3 / 2009年3月22日
533
556
 
534
557
  * バグの修正
@@ -609,6 +632,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
609
632
 
610
633
  * Nokogiri::HTML.fragment は XML::DocumentFragment (LH #32)で返す
611
634
 
635
+
636
+ == 1.1.x
637
+
612
638
  === 1.1.1
613
639
 
614
640
  * 新しい機能
@@ -641,6 +667,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
641
667
  * XML::Node#dup が引数任意のdepthを取る
642
668
  * XML::Node#add_previous_sibling が新しい兄弟ノードで返す
643
669
 
670
+
671
+ == 1.0.x
672
+
644
673
  === 1.0.7
645
674
 
646
675
  * バグの修正
@@ -1,4 +1,6 @@
1
- == 1.5.7 / unreleased
1
+ == 1.5.x
2
+
3
+ === 1.5.7 / unreleased
2
4
 
3
5
  * Bugfixes
4
6
  * SAX::Parser.parse_io throw an error when used with lower case encoding. #828
@@ -10,8 +12,12 @@
10
12
  * (JRuby) to_xhtml doesn't print the last slash for self-closing tags in JRuby. #834
11
13
  * (JRuby) Adding an EntityReference after a Text node mangles the entity in JRuby. #835
12
14
  * (JRuby) JRuby version inconsistency: nil for empty attributes. #818
15
+ * CSS queries for classes (e.g., ".foo") now treat all whitespace identically. #854
16
+ * Namespace behavior cleaned up and made consistent between JRuby and MRI. #846, #801 (Thanks, Michael Klein!)
17
+ * (MRI) SAX parser handles empty processing instructions. #845
18
+
13
19
 
14
- == 1.5.6 / 2012-12-19
20
+ === 1.5.6 / 2012-12-19
15
21
 
16
22
  * Features
17
23
 
@@ -49,7 +55,7 @@
49
55
  * (JRuby) builder requires textwrappers for valid utf8 in jruby, not in mri. #784
50
56
 
51
57
 
52
- == 1.5.5 / 2012-06-24
58
+ === 1.5.5 / 2012-06-24
53
59
 
54
60
  * Features
55
61
 
@@ -71,7 +77,7 @@
71
77
  * JRuby's Entity resolving should be consistent with C-Nokogiri #704, #647, #703
72
78
 
73
79
 
74
- == 1.5.4 / 2012-06-12
80
+ === 1.5.4 / 2012-06-12
75
81
 
76
82
  * Features
77
83
 
@@ -97,7 +103,7 @@
97
103
  Insert your own joke about double-negatives here.
98
104
 
99
105
 
100
- == 1.5.3 / 2012-06-01
106
+ === 1.5.3 / 2012-06-01
101
107
 
102
108
  * Features
103
109
 
@@ -127,12 +133,12 @@
127
133
  * (JRuby) Concurrency issue in XPath parsing. #682
128
134
 
129
135
 
130
- == 1.5.2 / 2012-03-09
136
+ === 1.5.2 / 2012-03-09
131
137
 
132
138
  Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631, #632.
133
139
 
134
140
 
135
- == 1.5.1 / 2012-03-09
141
+ === 1.5.1 / 2012-03-09
136
142
 
137
143
  * Features
138
144
 
@@ -177,7 +183,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
177
183
  * C14n cleanup and Node#canonicalize (thanks, Ivan Pirlik!) #563
178
184
 
179
185
 
180
- == 1.5.0 / 2011-07-01
186
+ === 1.5.0 / 2011-07-01
181
187
 
182
188
  * Notes
183
189
 
@@ -197,7 +203,7 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
197
203
  encoding.
198
204
  * Add support for <meta charset="...">.
199
205
 
200
- == 1.5.0 beta3 / 2010/12/02
206
+ === 1.5.0 beta3 / 2010/12/02
201
207
 
202
208
  * Notes
203
209
 
@@ -208,13 +214,13 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
208
214
 
209
215
  * Node#inner_text no longer returns nil. (JRuby) #264
210
216
 
211
- == 1.5.0 beta2 / 2010/07/30
217
+ === 1.5.0 beta2 / 2010/07/30
212
218
 
213
219
  * Notes
214
220
 
215
221
  * See changelog from 1.4.3
216
222
 
217
- == 1.5.0 beta1 / 2010/05/22
223
+ === 1.5.0 beta1 / 2010/05/22
218
224
 
219
225
  * Notes
220
226
 
@@ -226,6 +232,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
226
232
  * LibXML 2.6.16 and earlier are deprecated. Nokogiri will refuse to install.
227
233
  * FFI support is removed.
228
234
 
235
+
236
+ == 1.4.x
237
+
229
238
  === 1.4.7 / 2011-07-01
230
239
 
231
240
  * Bugfixes
@@ -437,6 +446,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
437
446
 
438
447
  * Hpricot compatibility layer removed
439
448
 
449
+
450
+ == 1.3.x
451
+
440
452
  === 1.3.3 / 2009/07/26
441
453
 
442
454
  * New Features
@@ -530,6 +542,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
530
542
  * Fixed a bug with attribute conditions in CSS selectors (GH#36)
531
543
  * Fixed intolerance of HTML attributes without values in Node#before/after/inner_html=. (GH#35)
532
544
 
545
+
546
+ == 1.2.x
547
+
533
548
  === 1.2.3 / 2009-03-22
534
549
 
535
550
  * Bugfixes
@@ -610,6 +625,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
610
625
 
611
626
  * Nokogiri::HTML.fragment now returns an XML::DocumentFragment (LH #32)
612
627
 
628
+
629
+ == 1.1.x
630
+
613
631
  === 1.1.1
614
632
 
615
633
  * New features
@@ -643,6 +661,9 @@ Repackaging of 1.5.1 with a gemspec that is compatible with older Rubies. #631,
643
661
  * XML::Node#dup takes an optional depth argument
644
662
  * XML::Node#add_previous_sibling returns new sibling node.
645
663
 
664
+
665
+ == 1.0.x
666
+
646
667
  === 1.0.7
647
668
 
648
669
  * Bugfixes
@@ -66,6 +66,7 @@ ext/java/nokogiri/internals/ParserContext.java
66
66
  ext/java/nokogiri/internals/ReaderNode.java
67
67
  ext/java/nokogiri/internals/SaveContextVisitor.java
68
68
  ext/java/nokogiri/internals/SchemaErrorHandler.java
69
+ ext/java/nokogiri/internals/UncloseableInputStream.java
69
70
  ext/java/nokogiri/internals/XmlDeclHandler.java
70
71
  ext/java/nokogiri/internals/XmlDomParserContext.java
71
72
  ext/java/nokogiri/internals/XmlSaxParser.java
data/Rakefile CHANGED
@@ -67,6 +67,19 @@ end
67
67
 
68
68
  # ----------------------------------------
69
69
 
70
+ def add_file_to_gem relative_path
71
+ target_path = File.join gem_build_path, relative_path
72
+ target_dir = File.dirname(target_path)
73
+ mkdir_p target_dir unless File.directory?(target_dir)
74
+ rm_f target_path
75
+ ln relative_path, target_path
76
+ HOE.spec.files += [relative_path]
77
+ end
78
+
79
+ def gem_build_path
80
+ File.join 'pkg', HOE.spec.full_name
81
+ end
82
+
70
83
  if java?
71
84
  # TODO: clean this section up.
72
85
  require "rake/javaextensiontask"
@@ -78,17 +91,15 @@ if java?
78
91
  ext.classpath = jars.map { |x| File.expand_path x }.join ':'
79
92
  end
80
93
 
81
- gem_build_path = File.join 'pkg', HOE.spec.full_name
82
-
83
94
  task gem_build_path => [:compile] do
84
- cp 'lib/nokogiri/nokogiri.jar', File.join(gem_build_path, 'lib', 'nokogiri')
85
- HOE.spec.files += ['lib/nokogiri/nokogiri.jar']
95
+ add_file_to_gem 'lib/nokogiri/nokogiri.jar'
86
96
  end
87
97
  else
88
98
  mingw_available = true
89
99
  begin
90
100
  require 'tasks/cross_compile'
91
101
  rescue
102
+ puts "WARNING: cross compilation not available: #{$!}"
92
103
  mingw_available = false
93
104
  end
94
105
  require "rake/extensiontask"
@@ -101,10 +112,10 @@ else
101
112
  if mingw_available
102
113
  ext.cross_compile = true
103
114
  ext.cross_platform = ["x86-mswin32-60", "x86-mingw32"]
104
- ext.cross_config_options << "--with-xml2-include=#{File.join($recipes[:libxml2].path, 'include', 'libxml2')}"
105
- ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes[:libxml2].path, 'lib')}"
106
- ext.cross_config_options << "--with-iconv-dir=#{$recipes[:libiconv].path}"
107
- ext.cross_config_options << "--with-xslt-dir=#{$recipes[:libxslt].path}"
115
+ ext.cross_config_options << "--with-xml2-include=#{File.join($recipes["libxml2"].path, 'include', 'libxml2')}"
116
+ ext.cross_config_options << "--with-xml2-lib=#{File.join($recipes["libxml2"].path, 'lib')}"
117
+ ext.cross_config_options << "--with-iconv-dir=#{$recipes["libiconv"].path}"
118
+ ext.cross_config_options << "--with-xslt-dir=#{$recipes["libxslt"].path}"
108
119
  ext.cross_config_options << "--with-zlib-dir=#{CROSS_DIR}"
109
120
  end
110
121
  end
@@ -207,7 +218,7 @@ task "gem:windows" => "gem" do
207
218
  rbconfig_19 = rake_compiler_config["rbconfig-1.9.2"]
208
219
  raise "rbconfig #{rbconfig_19} needs --export-all in its DLDFLAGS value" if File.read(rbconfig_19).split("\n").grep(/CONFIG\["DLDFLAGS"\].*--export-all/).empty?
209
220
 
210
- pkg_config_path = [:libxslt, :libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
221
+ pkg_config_path = %w[libxslt libxml2].collect { |pkg| File.join($recipes[pkg].path, "lib/pkgconfig") }.join(":")
211
222
  sh("env PKG_CONFIG_PATH=#{pkg_config_path} RUBY_CC_VERSION=#{ruby_cc_version} rake cross native gem") || raise("build failed!")
212
223
  end
213
224
 
@@ -179,11 +179,11 @@ public class XmlDocument extends XmlNode {
179
179
  if (node == null) return;
180
180
  String nodePrefix = node.getPrefix();
181
181
  if (nodePrefix == null) { // default namespace
182
- node.getOwnerDocument().renameNode(node, default_href, node.getNodeName());
182
+ NokogiriHelpers.renameNode(node, default_href, node.getNodeName());
183
183
  } else {
184
184
  XmlNamespace xmlNamespace = nsCache.get(nodePrefix);
185
185
  String href = rubyStringToString(xmlNamespace.href(context));
186
- node.getOwnerDocument().renameNode(node, href, node.getNodeName());
186
+ NokogiriHelpers.renameNode(node, href, node.getNodeName());
187
187
  }
188
188
  resolveNamespaceIfNecessary(context, node.getNextSibling(), default_href);
189
189
  NodeList children = node.getChildNodes();
@@ -358,7 +358,7 @@ public class XmlDocument extends XmlNode {
358
358
  Node node = xmlNode.node;
359
359
  if (node.getNodeType() == Node.ELEMENT_NODE) {
360
360
  node.setPrefix(null);
361
- node.getOwnerDocument().renameNode(node, null, node.getLocalName());
361
+ NokogiriHelpers.renameNode(node, null, node.getLocalName());
362
362
  NamedNodeMap attrs = node.getAttributes();
363
363
  for (int i=0; i<attrs.getLength(); i++) {
364
364
  Attr attr = (Attr) attrs.item(i);
@@ -366,7 +366,7 @@ public class XmlDocument extends XmlNode {
366
366
  ((org.w3c.dom.Element)node).removeAttributeNode(attr);
367
367
  } else {
368
368
  attr.setPrefix(null);
369
- attr.getOwnerDocument().renameNode(attr, null, attr.getLocalName());
369
+ NokogiriHelpers.renameNode(attr, null, attr.getLocalName());
370
370
  }
371
371
  }
372
372
  }
@@ -328,12 +328,15 @@ public class XmlNode extends RubyObject {
328
328
 
329
329
  Element element = null;
330
330
  String node_name = rubyStringToString(name);
331
- try {
332
- element = document.createElementNS(null, node_name);
333
- } catch (org.w3c.dom.DOMException e) {
334
- // issue#683 NAMESPACE_ERR is thrown from RDF::RDFXML::Writer.new
335
- // retry without namespace
331
+ String prefix = NokogiriHelpers.getPrefix(node_name);
332
+ if (prefix == null) {
336
333
  element = document.createElement(node_name);
334
+ } else {
335
+ String namespace_uri = null;
336
+ if (document.getDocumentElement() != null) {
337
+ namespace_uri = document.getDocumentElement().lookupNamespaceURI(prefix);
338
+ }
339
+ element = document.createElementNS(namespace_uri, node_name);
337
340
  }
338
341
  setNode(context, element);
339
342
  }
@@ -451,8 +454,16 @@ public class XmlNode extends RubyObject {
451
454
  public void relink_namespace(ThreadContext context) {
452
455
  if (node instanceof Element) {
453
456
  Element e = (Element) node;
457
+ String prefix = e.getPrefix();
458
+ String currentNS = e.getNamespaceURI();
459
+ if (prefix == null && currentNS == null) {
460
+ prefix = NokogiriHelpers.getPrefix(e.getNodeName());
461
+ } else if (currentNS != null) {
462
+ prefix = e.lookupPrefix(currentNS);
463
+ }
454
464
  e.getOwnerDocument().setStrictErrorChecking(false);
455
- e.getOwnerDocument().renameNode(e, e.lookupNamespaceURI(e.getPrefix()), e.getNodeName());
465
+ String nsURI = e.lookupNamespaceURI(prefix);
466
+ this.node = NokogiriHelpers.renameNode(e, nsURI, e.getNodeName());
456
467
 
457
468
  if (e.hasAttributes()) {
458
469
  NamedNodeMap attrs = e.getAttributes();
@@ -460,24 +471,28 @@ public class XmlNode extends RubyObject {
460
471
  for (int i = 0; i < attrs.getLength(); i++) {
461
472
  Attr attr = (Attr) attrs.item(i);
462
473
  String nsUri = "";
463
- String prefix = attr.getPrefix();
474
+ String attrPrefix = attr.getPrefix();
475
+ if (attrPrefix == null) {
476
+ attrPrefix = NokogiriHelpers.getPrefix(attr.getNodeName());
477
+ }
464
478
  String nodeName = attr.getNodeName();
465
479
  if ("xml".equals(prefix)) {
466
480
  nsUri = "http://www.w3.org/XML/1998/namespace";
467
- } else if ("xmlns".equals(prefix) || nodeName.equals("xmlns")) {
481
+ } else if ("xmlns".equals(attrPrefix) || nodeName.equals("xmlns")) {
468
482
  nsUri = "http://www.w3.org/2000/xmlns/";
469
483
  } else {
470
- nsUri = attr.getNamespaceURI();
484
+ nsUri = attr.lookupNamespaceURI(attrPrefix);
471
485
  }
472
486
  if (!(nsUri == null || "".equals(nsUri))) {
473
487
  XmlNamespace.createFromAttr(context.getRuntime(), attr);
474
488
  }
475
- e.getOwnerDocument().renameNode(attr, nsUri, nodeName);
489
+ NokogiriHelpers.renameNode(attr, nsUri, nodeName);
476
490
  }
477
491
  }
478
492
 
479
- if (e.hasChildNodes()) {
480
- ((XmlNodeSet) children(context)).relink_namespace(context);
493
+ if (this.node.hasChildNodes()) {
494
+ XmlNodeSet nodeSet = (XmlNodeSet)(children(context));
495
+ nodeSet.relink_namespace(context);
481
496
  }
482
497
  }
483
498
  }
@@ -536,7 +551,7 @@ public class XmlNode extends RubyObject {
536
551
  && oldPrefix.equals(rubyStringToString(ns.prefix(context))));
537
552
 
538
553
  if(update) {
539
- this.node.getOwnerDocument().renameNode(this.node, uri, this.node.getNodeName());
554
+ this.node = NokogiriHelpers.renameNode(this.node, uri, this.node.getNodeName());
540
555
  }
541
556
  }
542
557
 
@@ -576,7 +591,7 @@ public class XmlNode extends RubyObject {
576
591
  else namespaceOwner = node.getParentNode();
577
592
  XmlNamespace ns = XmlNamespace.createFromPrefixAndHref(namespaceOwner, prefix, href);
578
593
  if (node != namespaceOwner) {
579
- node.getOwnerDocument().renameNode(node, ns.getHref(), ns.getPrefix() + node.getLocalName());
594
+ this.node = NokogiriHelpers.renameNode(node, ns.getHref(), ns.getPrefix() + node.getLocalName());
580
595
  }
581
596
 
582
597
  updateNodeNamespaceIfNecessary(context, ns);
@@ -1172,7 +1187,7 @@ public class XmlNode extends RubyObject {
1172
1187
  @JRubyMethod(name = {"node_name=", "name="})
1173
1188
  public IRubyObject node_name_set(ThreadContext context, IRubyObject nodeName) {
1174
1189
  String newName = rubyStringToString(nodeName);
1175
- getOwnerDocument().renameNode(node, null, newName);
1190
+ this.node = NokogiriHelpers.renameNode(node, null, newName);
1176
1191
  setName(nodeName);
1177
1192
  return this;
1178
1193
  }
@@ -1190,6 +1205,8 @@ public class XmlNode extends RubyObject {
1190
1205
  String uri = null;
1191
1206
  if (prefix.equals("xml")) {
1192
1207
  uri = "http://www.w3.org/XML/1998/namespace";
1208
+ } else if (prefix.equals("xmlns")) {
1209
+ uri = "http://www.w3.org/2000/xmlns/";
1193
1210
  } else {
1194
1211
  uri = findNamespaceHref(context, prefix);
1195
1212
  }
@@ -1214,7 +1231,11 @@ public class XmlNode extends RubyObject {
1214
1231
  return namespace.getHref();
1215
1232
  }
1216
1233
  }
1217
- currentNode = (XmlNode) currentNode.parent(context);
1234
+ if (currentNode.parent(context).isNil()) {
1235
+ break;
1236
+ } else {
1237
+ currentNode = (XmlNode) currentNode.parent(context);
1238
+ }
1218
1239
  }
1219
1240
  return null;
1220
1241
  }
@@ -1261,7 +1282,7 @@ public class XmlNode extends RubyObject {
1261
1282
  String prefix = n.getPrefix();
1262
1283
  String href = n.getNamespaceURI();
1263
1284
  ((XmlDocument)doc).getNamespaceCache().remove(prefix == null ? "" : prefix, href);
1264
- n.getOwnerDocument().renameNode(n, null, n.getNodeName());
1285
+ this.node = NokogiriHelpers.renameNode(n, null, NokogiriHelpers.getLocalPart(n.getNodeName()));
1265
1286
  }
1266
1287
  } else {
1267
1288
  XmlNamespace ns = (XmlNamespace) namespace;
@@ -1270,7 +1291,14 @@ public class XmlNode extends RubyObject {
1270
1291
 
1271
1292
  // Assigning node = ...renameNode() or not seems to make no
1272
1293
  // difference. Why not? -pmahoney
1273
- node = node.getOwnerDocument().renameNode(node, href, NokogiriHelpers.newQName(prefix, node));
1294
+
1295
+ // It actually makes a great deal of difference. renameNode()
1296
+ // will operate in place if it can, but sometimes it can't.
1297
+ // The node you passed in *might* come back as you expect, but
1298
+ // it might not. It's much safer to throw away the original
1299
+ // and keep the return value. -mbklein
1300
+ String new_name = NokogiriHelpers.newQName(prefix, node);
1301
+ this.node = NokogiriHelpers.renameNode(node, href, new_name);
1274
1302
  }
1275
1303
 
1276
1304
  return this;
@@ -1485,7 +1513,7 @@ public class XmlNode extends RubyObject {
1485
1513
  XmlElement fragmentContext = ((XmlDocumentFragment)this).getFragmentContext();
1486
1514
  String namespace_uri = fragmentContext.node.getNamespaceURI();
1487
1515
  if (namespace_uri != null && namespace_uri.length() > 0) {
1488
- node.getOwnerDocument().renameNode(child, namespace_uri, child.getNodeName());
1516
+ NokogiriHelpers.renameNode(child, namespace_uri, child.getNodeName());
1489
1517
  }
1490
1518
  }
1491
1519
  }
@@ -1542,7 +1570,7 @@ public class XmlNode extends RubyObject {
1542
1570
  try {
1543
1571
  parentNode.replaceChild(otherNode, thisNode);
1544
1572
  if (otherNode.getNodeType() != Node.TEXT_NODE) {
1545
- otherNode.getOwnerDocument().renameNode(otherNode, thisNode.getNamespaceURI(), otherNode.getNodeName());
1573
+ NokogiriHelpers.renameNode(otherNode, thisNode.getNamespaceURI(), otherNode.getNodeName());
1546
1574
  }
1547
1575
  } catch (Exception e) {
1548
1576
  String prefix = "could not replace child: ";