nokogiri 1.5.4.rc3-java → 1.5.5-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.

Files changed (39) hide show
  1. data/CHANGELOG.ja.rdoc +35 -18
  2. data/CHANGELOG.rdoc +22 -1
  3. data/README.ja.rdoc +5 -5
  4. data/README.rdoc +9 -9
  5. data/ROADMAP.md +20 -20
  6. data/Rakefile +16 -5
  7. data/Y_U_NO_GEMSPEC.md +3 -3
  8. data/ext/java/nokogiri/HtmlElementDescription.java +1 -1
  9. data/ext/java/nokogiri/HtmlEntityLookup.java +1 -1
  10. data/ext/java/nokogiri/XmlComment.java +14 -5
  11. data/ext/java/nokogiri/XmlElement.java +1 -59
  12. data/ext/java/nokogiri/XmlNode.java +71 -19
  13. data/ext/java/nokogiri/XmlNodeSet.java +1 -1
  14. data/ext/java/nokogiri/XmlReader.java +48 -15
  15. data/ext/java/nokogiri/XmlSyntaxError.java +9 -4
  16. data/ext/java/nokogiri/XmlXpathContext.java +8 -7
  17. data/ext/java/nokogiri/internals/NokogiriHandler.java +7 -1
  18. data/ext/java/nokogiri/internals/NokogiriNamespaceCache.java +1 -5
  19. data/ext/java/nokogiri/internals/NokogiriNamespaceContext.java +1 -1
  20. data/ext/java/nokogiri/internals/NokogiriXPathVariableResolver.java +1 -1
  21. data/ext/java/nokogiri/internals/NokogiriXsltErrorListener.java +1 -1
  22. data/ext/java/nokogiri/internals/ParserContext.java +65 -104
  23. data/ext/java/nokogiri/internals/XmlDeclHandler.java +1 -1
  24. data/ext/java/nokogiri/internals/XmlDomParser.java +4 -6
  25. data/ext/java/nokogiri/internals/XmlDomParserContext.java +15 -12
  26. data/ext/nokogiri/xml_node.c +2 -2
  27. data/lib/nokogiri/css/parser.rb +75 -79
  28. data/lib/nokogiri/html/document.rb +1 -1
  29. data/lib/nokogiri/nokogiri.jar +0 -0
  30. data/lib/nokogiri/version.rb +1 -1
  31. data/lib/nokogiri/xml/node.rb +1 -1
  32. data/lib/nokogiri/xml/node/save_options.rb +1 -1
  33. data/test/html/test_document.rb +17 -0
  34. data/test/xml/test_document.rb +1 -1
  35. data/test/xml/test_dtd.rb +3 -7
  36. data/test/xml/test_entity_reference.rb +214 -0
  37. data/test/xml/test_node_reparenting.rb +9 -1
  38. data/test/xml/test_xpath.rb +28 -1
  39. metadata +17 -26
@@ -1,42 +1,59 @@
1
- == 1.5.4 / unreleased
1
+ == 1.5.5 / unreleased
2
2
 
3
3
  * Features
4
4
 
5
- * The "nokogiri" script now has more verbose output when passed the `--rng` option. #675 (Thanks, Dan Radez!)
6
- * Build support on hardened Debian systems that use `-Werror=format-security`. #680.
7
- * Better build support for systems with pkg-config. #584
8
- * Better build support for systems with multiple iconv installations.
5
+ * Much-improved support for JRuby in 1.9 mode! Yay!
9
6
 
10
7
  * Bugfixes
11
8
 
12
- * Segmentation fault when creating a comment node for a DocumentFragment. #677, #678.
13
- * Treat '.' as xpath in at() and search(). #690
9
+ * JRuby Nokogiri add_previous_sibling が以前は動いていたのに今は動かない(1.5.0 -> 1.5.1)。 #691 (ありがとう, John Shahid!)
10
+ * JRuby バーションは URL が引数にあたえられると HTML ドキュメントを作れない。 #674 (ありがとう, John Shahid!)
11
+ * JRuby バージョンは HTMLとして nil か "" が与えられると NullPointerException を投げる。 #699
12
+ * JRuby 1.9 モードでエラー, uncaught throw 'encoding_found', が発生する。 #673
13
+ * JRuby で US-ASCII にエンコードされた文字列が正しくないエンコードを返してくる。 #583
14
+ * 512 文字以上が与えられたときに XmlSaxPushParser が IndexOutOfBoundsException を投げる。#567, #615
15
+ * Xpath を評価した結果、空の NodeSet が帰ってくる場合に、NodeSet が持っている Document の decorate に失敗して例外が投げられる。#514
16
+ * JRuby で xpath を namespace 付きで指定した場合に、エラーが発生する。pull request #681 (ありがとう, Piotr Szmielew)
17
+ * JRuby で Nokogiri::XML::Node を継承したクラスを定義すると、namespace が表示されない。 #695
18
+ * JRuby で RDF::RDFXML::Writer をインスタンス化しようとすると NAMESPACE_ERR (org.w3c.dom.DOMException) が発生する. #683
19
+ * JRuby で xpath に namespaces を指定すると例外が発生する. #493
14
20
 
15
- * [MRI, Security] Default parse options for XML documents were
16
- changed to not make network connections during document parsing,
17
- to avoid XXE vulnerability. #693
18
21
 
19
- To re-enable this behavior, the configuration method `nononet` may
20
- be called, like this:
22
+ == 1.5.4 / 2012年6月12日
23
+
24
+ * Features
25
+
26
+ * "nokogiri" コマンドに `--rng` オプションが与えられと、より詳しい説明を表示するようになった。 #675 (ありがとう, Dan Radez!)
27
+ * `-Werror=format-security` CFLAGを使っている hardened な Debian 系 Linux でのビルドをサポート #680.
28
+ * pkg-config ありのシステム上でのよりよいビルドをサポート。 #584
29
+ * 複数の iconv がイストールされているシステムでのよりよいビルドをサポート。
30
+
31
+ * Bugfixes
32
+
33
+ * DocumentFragment をベースにしてコメントノードを作ったときに Segmentation fault する。 #677, #678.
34
+ * at() と search() メソッドで '.' をxpathとして扱う。 #690
35
+
36
+ * [MRI, Security] XML パース時のディフォルトのオプションを nonet に変更。これにより、ディフォルトでは
37
+ ドキュメントパース時にネットワーク接続を行わないようにし、XXE 脆弱性に対応した。#693
38
+
39
+ パース時にネットワークに接続して外部のドキュメントを見にいかせたい場合には、以下のように `nonoet` オプションを設定する:
21
40
 
22
41
  Nokogiri::XML::Document.parse(xml) { |config| config.nononet }
23
42
 
24
- Insert your own joke about double-negatives here.
43
+ ここに、自分ならではの二重否定のジョークをうめこむとなおよし。
25
44
 
26
45
 
27
- == 1.5.3 / 2012-06-01
46
+ == 1.5.3 / 2012年6月1日
28
47
 
29
48
  * Features
30
49
 
31
- * Support for "prefixless" CSS selectors ~, > and + like jQuery
32
- supports. #621, #623. (Thanks, David Lee!)
50
+ * jQuery のような "prefixless" CSS セレクタ, ~ >, + をサポート。#621, #623. (ありがとう, David Lee!)
33
51
  * Attempting to improve installation on homebrew 0.9 (with regards
34
52
  to iconv). Isn't package management convenient?
35
53
 
36
54
  * Bugfixes
37
55
 
38
- * Custom xpath functions with empty nodeset arguments cause a
39
- segfault. #634.
56
+ * カスタム xpath 関数が空の nodeset を引数に含む場合、segfault を起こす。 #634.
40
57
  * Nokogiri::XML::Node#css now works for XML documents with default
41
58
  namespaces when the rule contains attribute selector without
42
59
  namespace.
@@ -1,4 +1,25 @@
1
- == 1.5.4 / unreleased
1
+ == 1.5.5 / unreleased
2
+
3
+ * Features
4
+
5
+ * Much-improved support for JRuby in 1.9 mode! Yay!
6
+
7
+ * Bugfixes
8
+
9
+ * Regression in JRuby Nokogiri add_previous_sibling (1.5.0 -> 1.5.1) #691 (Thanks, John Shahid!)
10
+ * JRuby unable to create HTML doc if URL arg provided #674 (Thanks, John Shahid!)
11
+ * JRuby raises NullPointerException when given HTML document is nil or empty string. #699
12
+ * JRuby 1.9 error, uncaught throw 'encoding_found', has been fixed. #673
13
+ * Invalid encoding returned in JRuby with US-ASCII. #583
14
+ * XmlSaxPushParser raises IndexOutOfBoundsException when over 512 characters are given. #567, #615
15
+ * When xpath evaluation returns empty NodeSet, decorating NodeSet's base document raises exception. #514
16
+ * JRuby raises exception when xpath with namespace is specified. pull request #681 (Thanks, Piotr Szmielew)
17
+ * JRuby renders nodes without their namespace when subclassing Node. #695
18
+ * JRuby raises NAMESPACE_ERR (org.w3c.dom.DOMException) while instantiating RDF::RDFXML::Writer. #683
19
+ * JRuby is not able to use namespaces in xpath. #493
20
+
21
+
22
+ == 1.5.4 / 2012-06-12
2
23
 
3
24
  * Features
4
25
 
@@ -1,10 +1,10 @@
1
1
  = Nokogiri (鋸)
2
2
 
3
3
  * http://nokogiri.org/
4
- * http://github.com/tenderlove/nokogiri/wikis
5
- * http://github.com/tenderlove/nokogiri/tree/master
4
+ * http://github.com/sparklemotion/nokogiri/wikis
5
+ * http://github.com/sparklemotion/nokogiri/tree/master
6
6
  * http://groups.google.com/group/nokogiri-list
7
- * http://github.com/tenderlove/nokogiri/issues
7
+ * http://github.com/sparklemotion/nokogiri/issues
8
8
 
9
9
  == DESCRIPTION:
10
10
 
@@ -29,9 +29,9 @@ XML/HTMLの高速な解析と探索検索、ならびにCSS3セレクタとXPath
29
29
 
30
30
  * http://groups.google.com/group/nokogiri-list
31
31
 
32
- {バグ報告}[http://github.com/tenderlove/nokogiri/issues]
32
+ {バグ報告}[http://github.com/sparklemotion/nokogiri/issues]
33
33
 
34
- * http://github.com/tenderlove/nokogiri/issues
34
+ * http://github.com/sparklemotion/nokogiri/issues
35
35
 
36
36
  IRCのチャンネルはfreenodeの #nokogiri です。
37
37
 
@@ -1,10 +1,10 @@
1
- = Nokogiri {<img src="https://secure.travis-ci.org/tenderlove/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/tenderlove/nokogiri]
1
+ = Nokogiri {<img src="https://secure.travis-ci.org/sparklemotion/nokogiri.png?rvm=1.9.3" />}[http://travis-ci.org/sparklemotion/nokogiri]
2
2
 
3
3
  * http://nokogiri.org
4
- * http://github.com/tenderlove/nokogiri/wikis
5
- * http://github.com/tenderlove/nokogiri/tree/master
4
+ * http://github.com/sparklemotion/nokogiri/wikis
5
+ * http://github.com/sparklemotion/nokogiri/tree/master
6
6
  * http://groups.google.com/group/nokogiri-talk
7
- * http://github.com/tenderlove/nokogiri/issues
7
+ * http://github.com/sparklemotion/nokogiri/issues
8
8
 
9
9
  == DESCRIPTION:
10
10
 
@@ -34,10 +34,10 @@ is available here:
34
34
 
35
35
  * http://groups.google.com/group/nokogiri-talk
36
36
 
37
- The {bug tracker}[http://github.com/tenderlove/nokogiri/issues]
37
+ The {bug tracker}[http://github.com/sparklemotion/nokogiri/issues]
38
38
  is available here:
39
39
 
40
- * http://github.com/tenderlove/nokogiri/issues
40
+ * http://github.com/sparklemotion/nokogiri/issues
41
41
 
42
42
  The IRC channel is #nokogiri on freenode.
43
43
 
@@ -46,9 +46,9 @@ The IRC channel is #nokogiri on freenode.
46
46
  require 'nokogiri'
47
47
  require 'open-uri'
48
48
 
49
- # Get a Nokogiri::HTML:Document for the page we’re interested in...
49
+ # Get a Nokogiri::HTML::Document for the page we’re interested in...
50
50
 
51
- doc = Nokogiri::HTML(open('http://www.google.com/search?q=tenderlove'))
51
+ doc = Nokogiri::HTML(open('http://www.google.com/search?q=sparklemotion'))
52
52
 
53
53
  # Do funky things with it using Nokogiri::XML::Node methods...
54
54
 
@@ -151,7 +151,7 @@ Then run rake:
151
151
 
152
152
  Copyright (c) 2008 - 2012:
153
153
 
154
- * {Aaron Patterson}[http://tenderlovemaking.com]
154
+ * {Aaron Patterson}[http://sparklemotionmaking.com]
155
155
  * {Mike Dalessio}[http://mike.daless.io]
156
156
  * {Charles Nutter}[http://blog.headius.com]
157
157
  * {Sergio Arbeo}[http://www.serabe.com]
data/ROADMAP.md CHANGED
@@ -2,10 +2,10 @@
2
2
 
3
3
  ## overhaul serialize/pretty printing API
4
4
 
5
- * https://github.com/tenderlove/nokogiri/issues/530
5
+ * https://github.com/sparklemotion/nokogiri/issues/530
6
6
  XHTML formatting can't be turned off
7
7
 
8
- * https://github.com/tenderlove/nokogiri/issues/415
8
+ * https://github.com/sparklemotion/nokogiri/issues/415
9
9
  XML formatting should be no formatting
10
10
 
11
11
 
@@ -16,35 +16,35 @@
16
16
 
17
17
  ## Node should not be Enumerable; and should have a better attributes API
18
18
 
19
- * https://github.com/tenderlove/nokogiri/issues/679
19
+ * https://github.com/sparklemotion/nokogiri/issues/679
20
20
  Mixing in Enumerable has some unintended consequences; plus we want to improve the attributes API
21
21
 
22
- * (closed) https://github.com/tenderlove/nokogiri/issues/666
22
+ * (closed) https://github.com/sparklemotion/nokogiri/issues/666
23
23
  Some ideas for a better attributes API?
24
24
 
25
25
 
26
26
  ## improve CSS query parsing
27
27
 
28
- * https://github.com/tenderlove/nokogiri/issues/528
28
+ * https://github.com/sparklemotion/nokogiri/issues/528
29
29
  support `:not()` with a nontrivial argument, like `:not(div p.c)`
30
30
 
31
- * https://github.com/tenderlove/nokogiri/issues/451
31
+ * https://github.com/sparklemotion/nokogiri/issues/451
32
32
  chained :not pseudoselectors
33
33
 
34
34
  * better jQuery selector support:
35
- * https://github.com/tenderlove/nokogiri/issues/621
36
- * https://github.com/tenderlove/nokogiri/issues/342
37
- * https://github.com/tenderlove/nokogiri/issues/628
38
- * https://github.com/tenderlove/nokogiri/issues/652
39
- * https://github.com/tenderlove/nokogiri/issues/688
35
+ * https://github.com/sparklemotion/nokogiri/issues/621
36
+ * https://github.com/sparklemotion/nokogiri/issues/342
37
+ * https://github.com/sparklemotion/nokogiri/issues/628
38
+ * https://github.com/sparklemotion/nokogiri/issues/652
39
+ * https://github.com/sparklemotion/nokogiri/issues/688
40
40
 
41
- * https://github.com/tenderlove/nokogiri/issues/394
41
+ * https://github.com/sparklemotion/nokogiri/issues/394
42
42
  nth-of-type is wrong, and possibly other selectors as well
43
43
 
44
- * https://github.com/tenderlove/nokogiri/issues/309
44
+ * https://github.com/sparklemotion/nokogiri/issues/309
45
45
  incorrect query being executed
46
46
 
47
- * https://github.com/tenderlove/nokogiri/issues/350
47
+ * https://github.com/sparklemotion/nokogiri/issues/350
48
48
  :has is wrong?
49
49
 
50
50
 
@@ -52,15 +52,15 @@
52
52
 
53
53
  * there are a few tickets about searches not working properly if you
54
54
  use or do not use the context node as part of the search.
55
- - https://github.com/tenderlove/nokogiri/issues/213
56
- - https://github.com/tenderlove/nokogiri/issues/370
57
- - https://github.com/tenderlove/nokogiri/issues/454
58
- - https://github.com/tenderlove/nokogiri/issues/572
55
+ - https://github.com/sparklemotion/nokogiri/issues/213
56
+ - https://github.com/sparklemotion/nokogiri/issues/370
57
+ - https://github.com/sparklemotion/nokogiri/issues/454
58
+ - https://github.com/sparklemotion/nokogiri/issues/572
59
59
 
60
60
 
61
61
  ## Better Syntax for custom XPath function handler
62
62
 
63
- * https://github.com/tenderlove/nokogiri/pull/464
63
+ * https://github.com/sparklemotion/nokogiri/pull/464
64
64
 
65
65
 
66
66
  ## Better Syntax around Node#xpath and NodeSet#xpath
@@ -68,7 +68,7 @@
68
68
  * look at those methods, and use of Node#extract_params in Node#{css,search}
69
69
  * we should standardize on a hash of options for these and other calls
70
70
  * what should NodeSet#xpath return?
71
- * https://github.com/tenderlove/nokogiri/issues/656
71
+ * https://github.com/sparklemotion/nokogiri/issues/656
72
72
 
73
73
  ## Encoding
74
74
 
data/Rakefile CHANGED
@@ -23,6 +23,7 @@ HOE = Hoe.spec 'nokogiri' do
23
23
  developer 'Aaron Patterson', 'aaronp@rubyforge.org'
24
24
  developer 'Mike Dalessio', 'mike.dalessio@gmail.com'
25
25
  developer 'Yoko Harada', 'yokolet@gmail.com'
26
+ developer 'Tim Elliott', 'tle@holymonkey.com'
26
27
 
27
28
  self.readme_file = ['README', ENV['HLANG'], 'rdoc'].compact.join('.')
28
29
  self.history_file = ['CHANGELOG', ENV['HLANG'], 'rdoc'].compact.join('.')
@@ -33,8 +34,8 @@ HOE = Hoe.spec 'nokogiri' do
33
34
  'nokogiri.gemspec',
34
35
  'lib/nokogiri/nokogiri.{bundle,jar,rb,so}',
35
36
  'lib/nokogiri/1.{8,9}',
36
- GENERATED_PARSER,
37
- GENERATED_TOKENIZER
37
+ # GENERATED_PARSER,
38
+ # GENERATED_TOKENIZER
38
39
  ]
39
40
 
40
41
  self.extra_dev_deps += [
@@ -44,10 +45,15 @@ HOE = Hoe.spec 'nokogiri' do
44
45
  ["hoe-git", ">= 1.4"],
45
46
  ["mini_portile", ">= 0.2.2"],
46
47
  ["minitest", "~> 2.2.2"],
47
- ["racc", ">= 1.4.6"],
48
- ["rake-compiler", "= 0.8.0"],
49
- ["rexical", ">= 1.0.5"],
48
+ ["rake", ">= 0.9"],
49
+ ["rake-compiler", "= 0.8.0"]
50
50
  ]
51
+ if ! java?
52
+ self.extra_dev_deps += [
53
+ ["racc", ">= 1.4.6"],
54
+ ["rexical", ">= 1.0.5"]
55
+ ]
56
+ end
51
57
 
52
58
  if java?
53
59
  self.spec_extras = { :platform => 'java' }
@@ -139,7 +145,12 @@ end
139
145
 
140
146
  require 'tasks/test'
141
147
 
148
+ task :java_debug do
149
+ ENV['JAVA_OPTS'] = '-Xdebug -Xrunjdwp:transport=dt_socket,address=8000,server=y,suspend=y' if java? && ENV['JAVA_DEBUG']
150
+ end
151
+
142
152
  Rake::Task[:test].prerequisites << :compile
153
+ Rake::Task[:test].prerequisites << :java_debug
143
154
  Rake::Task[:test].prerequisites << :check_extra_deps unless java?
144
155
  if Hoe.plugins.include?(:debugging)
145
156
  ['valgrind', 'valgrind:mem', 'valgrind:mem0'].each do |task_name|
@@ -16,9 +16,9 @@ OHAI! Thank you for asking this question!
16
16
  Team Nokogiri gets asked this pretty frequently. Just a sample from
17
17
  the historical record:
18
18
 
19
- * [Issue #274](https://github.com/tenderlove/nokogiri/issues/274)
20
- * [Issue #371](https://github.com/tenderlove/nokogiri/issues/371)
21
- * [A commit removing nokogiri.gemspec](https://github.com/tenderlove/nokogiri/commit/7f17a643a05ca381d65131515b54d4a3a61ca2e1#commitcomment-667477)
19
+ * [Issue #274](https://github.com/sparklemotion/nokogiri/issues/274)
20
+ * [Issue #371](https://github.com/sparklemotion/nokogiri/issues/371)
21
+ * [A commit removing nokogiri.gemspec](https://github.com/sparklemotion/nokogiri/commit/7f17a643a05ca381d65131515b54d4a3a61ca2e1#commitcomment-667477)
22
22
  * [A nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/4706b002e492d23f)
23
23
  * [Another nokogiri-talk thread](http://groups.google.com/group/nokogiri-talk/browse_thread/thread/0b201bb80ea3eea0)
24
24
 
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2011:
4
+ * Copyright (c) 2008 - 2012:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2011:
4
+ * Copyright (c) 2008 - 2012:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2011:
4
+ * Copyright (c) 2008 - 2012:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -69,10 +69,19 @@ public class XmlComment extends XmlNode {
69
69
  IRubyObject doc = args[0];
70
70
  IRubyObject text = args[1];
71
71
 
72
- XmlDocument xmlDoc = (XmlDocument) doc;
73
- Document document = xmlDoc.getDocument();
74
- Node node = document.createComment(rubyStringToString(text));
75
- setNode(context, node);
72
+ XmlDocument xmlDoc = null;
73
+ if (doc instanceof XmlDocument) {
74
+ xmlDoc = (XmlDocument) doc;
75
+
76
+ } else if (doc instanceof XmlNode) {
77
+ XmlNode xmlNode = (XmlNode) doc;
78
+ xmlDoc = (XmlDocument)xmlNode.document(context);
79
+ }
80
+ if (xmlDoc != null) {
81
+ Document document = xmlDoc.getDocument();
82
+ Node node = document.createComment(rubyStringToString(text));
83
+ setNode(context, node);
84
+ }
76
85
  }
77
86
 
78
87
  @Override
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * (The MIT License)
3
3
  *
4
- * Copyright (c) 2008 - 2011:
4
+ * Copyright (c) 2008 - 2012:
5
5
  *
6
6
  * * {Aaron Patterson}[http://tenderlovemaking.com]
7
7
  * * {Mike Dalessio}[http://mike.daless.io]
@@ -32,20 +32,15 @@
32
32
 
33
33
  package nokogiri;
34
34
 
35
- import static nokogiri.internals.NokogiriHelpers.rubyStringToString;
36
35
  import nokogiri.internals.SaveContextVisitor;
37
36
 
38
37
  import org.jruby.Ruby;
39
38
  import org.jruby.RubyArray;
40
39
  import org.jruby.RubyClass;
41
40
  import org.jruby.anno.JRubyClass;
42
- import org.jruby.anno.JRubyMethod;
43
41
  import org.jruby.javasupport.util.RuntimeHelpers;
44
42
  import org.jruby.runtime.ThreadContext;
45
- import org.jruby.runtime.builtin.IRubyObject;
46
- import org.w3c.dom.Attr;
47
43
  import org.w3c.dom.Element;
48
- import org.w3c.dom.NamedNodeMap;
49
44
  import org.w3c.dom.Node;
50
45
 
51
46
  /**
@@ -79,59 +74,6 @@ public class XmlElement extends XmlNode {
79
74
  }
80
75
  }
81
76
  }
82
-
83
- @Override
84
- @JRubyMethod(name = {"add_namespace_definition", "add_namespace"})
85
- public IRubyObject add_namespace_definition(ThreadContext context,
86
- IRubyObject prefix,
87
- IRubyObject href) {
88
- Element element = (Element) node;
89
-
90
- final String uri = "http://www.w3.org/2000/xmlns/";
91
- String qName =
92
- prefix.isNil() ? "xmlns" : "xmlns:" + rubyStringToString(prefix);
93
- element.setAttributeNS(uri, qName, rubyStringToString(href));
94
-
95
- XmlNamespace ns = (XmlNamespace) super.add_namespace_definition(context, prefix, href);
96
- updateNodeNamespaceIfNecessary(context, ns);
97
-
98
- return ns;
99
- }
100
-
101
- @Override
102
- public boolean isElement() { return true; }
103
-
104
- @Override
105
- public void relink_namespace(ThreadContext context) {
106
- Element e = (Element) node;
107
-
108
- e.getOwnerDocument().renameNode(e, e.lookupNamespaceURI(e.getPrefix()), e.getNodeName());
109
-
110
- if(e.hasAttributes()) {
111
- NamedNodeMap attrs = e.getAttributes();
112
-
113
- for(int i = 0; i < attrs.getLength(); i++) {
114
- Attr attr = (Attr) attrs.item(i);
115
- String nsUri = "";
116
- String prefix = attr.getPrefix();
117
- String nodeName = attr.getNodeName();
118
- if("xml".equals(prefix)) {
119
- nsUri = "http://www.w3.org/XML/1998/namespace";
120
- } else if("xmlns".equals(prefix) || nodeName.equals("xmlns")) {
121
- nsUri = "http://www.w3.org/2000/xmlns/";
122
- } else {
123
- nsUri = attr.lookupNamespaceURI(nodeName);
124
- }
125
-
126
- e.getOwnerDocument().renameNode(attr, nsUri, nodeName);
127
-
128
- }
129
- }
130
-
131
- if(e.hasChildNodes()) {
132
- ((XmlNodeSet) children(context)).relink_namespace(context);
133
- }
134
- }
135
77
 
136
78
  @Override
137
79
  public void accept(ThreadContext context, SaveContextVisitor visitor) {