nokogiri 1.13.9-java → 1.14.0.rc1-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 (117) hide show
  1. checksums.yaml +4 -4
  2. data/Gemfile +33 -0
  3. data/LICENSE-DEPENDENCIES.md +830 -509
  4. data/README.md +18 -11
  5. data/dependencies.yml +25 -7
  6. data/ext/java/nokogiri/Html4Document.java +2 -0
  7. data/ext/java/nokogiri/Html4ElementDescription.java +9 -9
  8. data/ext/java/nokogiri/Html4EntityLookup.java +14 -3
  9. data/ext/java/nokogiri/Html4SaxParserContext.java +2 -2
  10. data/ext/java/nokogiri/Html4SaxPushParser.java +3 -0
  11. data/ext/java/nokogiri/NokogiriService.java +1 -24
  12. data/ext/java/nokogiri/XmlAttr.java +1 -1
  13. data/ext/java/nokogiri/XmlAttributeDecl.java +2 -1
  14. data/ext/java/nokogiri/XmlCdata.java +2 -1
  15. data/ext/java/nokogiri/XmlComment.java +2 -1
  16. data/ext/java/nokogiri/XmlDocument.java +5 -6
  17. data/ext/java/nokogiri/XmlDocumentFragment.java +2 -1
  18. data/ext/java/nokogiri/XmlDtd.java +4 -3
  19. data/ext/java/nokogiri/XmlElement.java +1 -0
  20. data/ext/java/nokogiri/XmlElementContent.java +4 -1
  21. data/ext/java/nokogiri/XmlElementDecl.java +3 -1
  22. data/ext/java/nokogiri/XmlEntityDecl.java +2 -0
  23. data/ext/java/nokogiri/XmlEntityReference.java +1 -0
  24. data/ext/java/nokogiri/XmlNamespace.java +2 -0
  25. data/ext/java/nokogiri/XmlNode.java +39 -24
  26. data/ext/java/nokogiri/XmlNodeSet.java +10 -7
  27. data/ext/java/nokogiri/XmlProcessingInstruction.java +1 -0
  28. data/ext/java/nokogiri/XmlReader.java +4 -3
  29. data/ext/java/nokogiri/XmlRelaxng.java +1 -0
  30. data/ext/java/nokogiri/XmlSaxParserContext.java +1 -0
  31. data/ext/java/nokogiri/XmlSaxPushParser.java +3 -0
  32. data/ext/java/nokogiri/XmlSchema.java +4 -2
  33. data/ext/java/nokogiri/XmlSyntaxError.java +1 -0
  34. data/ext/java/nokogiri/XmlText.java +1 -0
  35. data/ext/java/nokogiri/XmlXpathContext.java +2 -0
  36. data/ext/java/nokogiri/XsltStylesheet.java +16 -13
  37. data/ext/java/nokogiri/internals/HtmlDomParserContext.java +3 -2
  38. data/ext/java/nokogiri/internals/NokogiriHandler.java +2 -2
  39. data/ext/java/nokogiri/internals/NokogiriHelpers.java +4 -5
  40. data/ext/java/nokogiri/internals/NokogiriXPathFunction.java +3 -3
  41. data/ext/java/nokogiri/internals/ParserContext.java +2 -0
  42. data/ext/java/nokogiri/internals/ReaderNode.java +1 -1
  43. data/ext/java/nokogiri/internals/SaveContextVisitor.java +4 -2
  44. data/ext/java/nokogiri/internals/SchemaErrorHandler.java +2 -2
  45. data/ext/java/nokogiri/internals/XmlDomParserContext.java +2 -1
  46. data/ext/java/nokogiri/internals/c14n/Canonicalizer.java +1 -0
  47. data/ext/java/nokogiri/internals/dom2dtm/DOM2DTM.java +5 -4
  48. data/ext/nokogiri/extconf.rb +79 -20
  49. data/ext/nokogiri/gumbo.c +19 -9
  50. data/ext/nokogiri/html4_document.c +1 -1
  51. data/ext/nokogiri/html4_entity_lookup.c +1 -1
  52. data/ext/nokogiri/html4_sax_parser_context.c +0 -5
  53. data/ext/nokogiri/nokogiri.c +32 -51
  54. data/ext/nokogiri/xml_attribute_decl.c +1 -1
  55. data/ext/nokogiri/xml_cdata.c +1 -1
  56. data/ext/nokogiri/xml_document.c +16 -11
  57. data/ext/nokogiri/xml_element_content.c +2 -2
  58. data/ext/nokogiri/xml_element_decl.c +1 -1
  59. data/ext/nokogiri/xml_encoding_handler.c +2 -2
  60. data/ext/nokogiri/xml_namespace.c +38 -8
  61. data/ext/nokogiri/xml_node.c +286 -26
  62. data/ext/nokogiri/xml_node_set.c +0 -2
  63. data/ext/nokogiri/xml_reader.c +44 -20
  64. data/ext/nokogiri/xml_relax_ng.c +0 -2
  65. data/ext/nokogiri/xml_sax_parser.c +22 -16
  66. data/ext/nokogiri/xml_sax_parser_context.c +0 -5
  67. data/ext/nokogiri/xml_sax_push_parser.c +0 -2
  68. data/ext/nokogiri/xml_schema.c +0 -2
  69. data/ext/nokogiri/xml_xpath_context.c +87 -83
  70. data/ext/nokogiri/xslt_stylesheet.c +14 -13
  71. data/gumbo-parser/Makefile +10 -0
  72. data/lib/nokogiri/css/node.rb +2 -2
  73. data/lib/nokogiri/css/xpath_visitor.rb +3 -1
  74. data/lib/nokogiri/css.rb +6 -0
  75. data/lib/nokogiri/encoding_handler.rb +57 -0
  76. data/lib/nokogiri/extension.rb +3 -2
  77. data/lib/nokogiri/html4/document.rb +2 -121
  78. data/lib/nokogiri/html4/element_description_defaults.rb +6 -12
  79. data/lib/nokogiri/html4/encoding_reader.rb +121 -0
  80. data/lib/nokogiri/html4.rb +1 -0
  81. data/lib/nokogiri/html5/document.rb +113 -36
  82. data/lib/nokogiri/html5/document_fragment.rb +9 -2
  83. data/lib/nokogiri/html5/node.rb +3 -5
  84. data/lib/nokogiri/html5.rb +127 -216
  85. data/lib/nokogiri/jruby/dependencies.rb +1 -19
  86. data/lib/{isorelax.jar → nokogiri/jruby/isorelax/isorelax/20030108/isorelax-20030108.jar} +0 -0
  87. data/lib/nokogiri/jruby/net/sf/saxon/Saxon-HE/9.6.0-4/Saxon-HE-9.6.0-4.jar +0 -0
  88. data/lib/nokogiri/jruby/net/sourceforge/htmlunit/neko-htmlunit/2.63.0/neko-htmlunit-2.63.0.jar +0 -0
  89. data/lib/nokogiri/jruby/nokogiri_jars.rb +43 -0
  90. data/lib/nokogiri/jruby/nu/validator/jing/20200702VNU/jing-20200702VNU.jar +0 -0
  91. data/lib/nokogiri/jruby/org/nokogiri/nekodtd/0.1.11.noko1/nekodtd-0.1.11.noko1.jar +0 -0
  92. data/lib/{serializer.jar → nokogiri/jruby/xalan/serializer/2.7.2/serializer-2.7.2.jar} +0 -0
  93. data/lib/{xalan.jar → nokogiri/jruby/xalan/xalan/2.7.2/xalan-2.7.2.jar} +0 -0
  94. data/lib/{xercesImpl.jar → nokogiri/jruby/xerces/xercesImpl/2.12.2/xercesImpl-2.12.2.jar} +0 -0
  95. data/lib/{xml-apis.jar → nokogiri/jruby/xml-apis/xml-apis/1.4.01/xml-apis-1.4.01.jar} +0 -0
  96. data/lib/nokogiri/nokogiri.jar +0 -0
  97. data/lib/nokogiri/version/constant.rb +1 -1
  98. data/lib/nokogiri/version/info.rb +11 -10
  99. data/lib/nokogiri/xml/attr.rb +49 -0
  100. data/lib/nokogiri/xml/builder.rb +1 -1
  101. data/lib/nokogiri/xml/document.rb +102 -54
  102. data/lib/nokogiri/xml/document_fragment.rb +49 -6
  103. data/lib/nokogiri/xml/namespace.rb +42 -0
  104. data/lib/nokogiri/xml/node/save_options.rb +4 -2
  105. data/lib/nokogiri/xml/node.rb +190 -35
  106. data/lib/nokogiri/xml/node_set.rb +87 -9
  107. data/lib/nokogiri/xml/parse_options.rb +127 -48
  108. data/lib/nokogiri/xml/pp/node.rb +6 -4
  109. data/lib/nokogiri/xml/processing_instruction.rb +2 -1
  110. data/lib/nokogiri/xml/sax/parser.rb +2 -3
  111. data/lib/nokogiri/xslt.rb +1 -1
  112. data/lib/nokogiri.rb +3 -11
  113. metadata +62 -260
  114. data/ext/java/nokogiri/EncodingHandler.java +0 -111
  115. data/lib/jing.jar +0 -0
  116. data/lib/nekodtd.jar +0 -0
  117. data/lib/nekohtml.jar +0 -0
@@ -55,6 +55,8 @@ import nokogiri.internals.XmlDomParserContext;
55
55
  @JRubyClass(name = "Nokogiri::XML::Node")
56
56
  public class XmlNode extends RubyObject
57
57
  {
58
+ private static final long serialVersionUID = 1L;
59
+
58
60
  protected static final String TEXT_WRAPPER_NAME = "nokogiri_text_wrapper";
59
61
 
60
62
  /** The underlying Node object. */
@@ -598,22 +600,23 @@ public class XmlNode extends RubyObject
598
600
  hrefStr = rubyStringToString(href.convertToString());
599
601
  }
600
602
 
601
- NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCache(node);
602
- XmlNamespace cachedNamespace = nsCache.get(prefixStr, hrefStr);
603
- if (cachedNamespace != null) { return cachedNamespace; }
604
-
605
603
  Node namespaceOwner;
606
604
  if (node.getNodeType() == Node.ELEMENT_NODE) {
607
605
  namespaceOwner = node;
608
- Element element = (Element) node;
609
606
  // adds namespace as node's attribute
610
607
  String qName = prefix.isNil() ? "xmlns" : "xmlns:" + prefixStr;
611
- element.setAttributeNS("http://www.w3.org/2000/xmlns/", qName, hrefStr);
612
- } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) { namespaceOwner = ((Attr) node).getOwnerElement(); }
613
- else { namespaceOwner = node.getParentNode(); }
614
-
615
- XmlNamespace ns = XmlNamespace.createImpl(namespaceOwner, prefix, prefixStr, href, hrefStr);
608
+ ((Element)node).setAttributeNS("http://www.w3.org/2000/xmlns/", qName, hrefStr);
609
+ } else if (node.getNodeType() == Node.ATTRIBUTE_NODE) {
610
+ namespaceOwner = ((Attr) node).getOwnerElement();
611
+ } else {
612
+ namespaceOwner = node.getParentNode();
613
+ }
616
614
 
615
+ NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCache(node);
616
+ XmlNamespace ns = nsCache.get(prefixStr, hrefStr);
617
+ if (ns == null) {
618
+ ns = XmlNamespace.createImpl(namespaceOwner, prefix, prefixStr, href, hrefStr);
619
+ }
617
620
  if (node != namespaceOwner) {
618
621
  node = NokogiriHelpers.renameNode(node, ns.getHref(), ns.getPrefix() + ':' + node.getLocalName());
619
622
  }
@@ -658,7 +661,7 @@ public class XmlNode extends RubyObject
658
661
  NamedNodeMap nodeMap = this.node.getAttributes();
659
662
 
660
663
  if (nodeMap == null) { return runtime.newEmptyArray(); }
661
- RubyArray attr = runtime.newArray(nodeMap.getLength());
664
+ RubyArray<?> attr = runtime.newArray(nodeMap.getLength());
662
665
 
663
666
  final XmlDocument doc = document(context.runtime);
664
667
  for (int i = 0; i < nodeMap.getLength(); i++) {
@@ -848,8 +851,8 @@ public class XmlNode extends RubyObject
848
851
 
849
852
  XmlDocument doc = ctx.parse(context, klass, context.nil);
850
853
 
851
- RubyArray documentErrors = getErrors(document);
852
- RubyArray docErrors = getErrors(doc);
854
+ RubyArray<?> documentErrors = getErrors(document);
855
+ RubyArray<?> docErrors = getErrors(doc);
853
856
  if (checkNewErrors(documentErrors, docErrors)) {
854
857
  for (int i = 0; i < docErrors.getLength(); i++) {
855
858
  documentErrors.append(docErrors.entry(i));
@@ -871,7 +874,7 @@ public class XmlNode extends RubyObject
871
874
  return XmlNodeSet.newNodeSet(context.runtime, nodes, this);
872
875
  }
873
876
 
874
- private static RubyArray
877
+ private static RubyArray<?>
875
878
  getErrors(XmlDocument document)
876
879
  {
877
880
  IRubyObject obj = document.getInstanceVariable("@errors");
@@ -880,7 +883,7 @@ public class XmlNode extends RubyObject
880
883
  }
881
884
 
882
885
  private static boolean
883
- checkNewErrors(RubyArray baseErrors, RubyArray newErrors)
886
+ checkNewErrors(RubyArray<?> baseErrors, RubyArray<?> newErrors)
884
887
  {
885
888
  int length = ((RubyArray) newErrors.op_diff(baseErrors)).size();
886
889
  return length > 0;
@@ -1191,7 +1194,7 @@ public class XmlNode extends RubyObject
1191
1194
  * of this node.
1192
1195
  */
1193
1196
  @JRubyMethod
1194
- public IRubyObject
1197
+ public RubyArray<?>
1195
1198
  namespace_definitions(ThreadContext context)
1196
1199
  {
1197
1200
  // don't use namespace_definitions cache anymore since
@@ -1203,7 +1206,19 @@ public class XmlNode extends RubyObject
1203
1206
  if (doc instanceof Html4Document) { return context.runtime.newEmptyArray(); }
1204
1207
 
1205
1208
  List<XmlNamespace> namespaces = doc.getNamespaceCache().get(node);
1206
- return context.runtime.newArray((List) namespaces);
1209
+ return RubyArray.newArray(context.runtime, namespaces);
1210
+
1211
+ // // TODO: I think this implementation would be better but there are edge cases
1212
+ // // See https://github.com/sparklemotion/nokogiri/issues/2543
1213
+ // RubyArray<?> nsdefs = RubyArray.newArray(context.getRuntime());
1214
+ // NamedNodeMap attrs = node.getAttributes();
1215
+ // for (int j = 0 ; j < attrs.getLength() ; j++) {
1216
+ // Attr attr = (Attr)attrs.item(j);
1217
+ // if ("http://www.w3.org/2000/xmlns/" == attr.getNamespaceURI()) {
1218
+ // nsdefs.append(XmlNamespace.createFromAttr(context.getRuntime(), attr));
1219
+ // }
1220
+ // }
1221
+ // return nsdefs;
1207
1222
  }
1208
1223
 
1209
1224
  /**
@@ -1211,7 +1226,7 @@ public class XmlNode extends RubyObject
1211
1226
  * on any ancestor node.
1212
1227
  */
1213
1228
  @JRubyMethod
1214
- public RubyArray
1229
+ public RubyArray<?>
1215
1230
  namespace_scopes(ThreadContext context)
1216
1231
  {
1217
1232
  final XmlDocument doc = document(context.runtime);
@@ -1228,7 +1243,7 @@ public class XmlNode extends RubyObject
1228
1243
  }
1229
1244
  if (previousNode == null) { return context.runtime.newEmptyArray(); }
1230
1245
 
1231
- final RubyArray scoped_namespaces = context.runtime.newArray();
1246
+ final RubyArray<?> scoped_namespaces = context.runtime.newArray();
1232
1247
  final HashSet<String> prefixes_in_scope = new HashSet<String>(8);
1233
1248
  NokogiriNamespaceCache nsCache = NokogiriHelpers.getNamespaceCache(previousNode);
1234
1249
  for (Node previous = previousNode; previous != null;) {
@@ -1438,7 +1453,7 @@ public class XmlNode extends RubyObject
1438
1453
  XmlNode currentNode = this;
1439
1454
  final XmlDocument doc = document(context.runtime);
1440
1455
  while (currentNode != doc) {
1441
- RubyArray namespaces = currentNode.namespace_scopes(context);
1456
+ RubyArray<?> namespaces = currentNode.namespace_scopes(context);
1442
1457
  for (int i = 0; i < namespaces.size(); i++) {
1443
1458
  XmlNamespace namespace = (XmlNamespace) namespaces.eltInternal(i);
1444
1459
  if (namespace.hasPrefix(prefix)) { return namespace.getHref(); }
@@ -1891,7 +1906,7 @@ public class XmlNode extends RubyObject
1891
1906
  process_xincludes(ThreadContext context, IRubyObject options)
1892
1907
  {
1893
1908
  XmlDocument xmlDocument = (XmlDocument)document(context);
1894
- RubyArray errors = (RubyArray)xmlDocument.getInstanceVariable("@errors");
1909
+ RubyArray<?> errors = (RubyArray)xmlDocument.getInstanceVariable("@errors");
1895
1910
  while (errors.getLength() > 0) {
1896
1911
  XmlSyntaxError error = (XmlSyntaxError)errors.shift(context);
1897
1912
  if (error.toString().contains("Include operation failed")) {
@@ -1911,11 +1926,11 @@ public class XmlNode extends RubyObject
1911
1926
 
1912
1927
  @SuppressWarnings("unchecked")
1913
1928
  @Override
1914
- public Object
1915
- toJava(final Class target)
1929
+ public <T> T
1930
+ toJava(Class<T> target)
1916
1931
  {
1917
1932
  if (target == Object.class || Node.class.isAssignableFrom(target)) {
1918
- return getNode();
1933
+ return (T)getNode();
1919
1934
  }
1920
1935
  return super.toJava(target);
1921
1936
  }
@@ -28,6 +28,7 @@ import org.w3c.dom.NodeList;
28
28
  @JRubyClass(name = "Nokogiri::XML::NodeSet")
29
29
  public class XmlNodeSet extends RubyObject implements NodeList
30
30
  {
31
+ private static final long serialVersionUID = 1L;
31
32
 
32
33
  IRubyObject[] nodes;
33
34
 
@@ -350,12 +351,14 @@ public class XmlNodeSet extends RubyObject implements NodeList
350
351
  if (indexOrRange instanceof RubyFixnum) {
351
352
  return slice(context, ((RubyFixnum) indexOrRange).getIntValue());
352
353
  }
353
-
354
- int[] begLen = new int[2];
355
- rangeBeginLength(context, indexOrRange, nodes.length, begLen);
356
- int min = begLen[0];
357
- int max = begLen[1];
358
- return subseq(context, min, max - min);
354
+ if (indexOrRange instanceof RubyRange) {
355
+ int[] begLen = new int[2];
356
+ rangeBeginLength(context, indexOrRange, nodes.length, begLen);
357
+ int min = begLen[0];
358
+ int max = begLen[1];
359
+ return subseq(context, min, max - min);
360
+ }
361
+ throw context.runtime.newTypeError("index must be an Integer or a Range");
359
362
  }
360
363
 
361
364
  IRubyObject
@@ -407,7 +410,7 @@ public class XmlNodeSet extends RubyObject implements NodeList
407
410
  }
408
411
 
409
412
  @JRubyMethod(name = {"to_a", "to_ary"})
410
- public RubyArray
413
+ public RubyArray<?>
411
414
  to_a(ThreadContext context)
412
415
  {
413
416
  return context.runtime.newArrayNoCopy(nodes);
@@ -24,6 +24,7 @@ import nokogiri.internals.SaveContextVisitor;
24
24
  @JRubyClass(name = "Nokogiri::XML::ProcessingInstruction", parent = "Nokogiri::XML::Node")
25
25
  public class XmlProcessingInstruction extends XmlNode
26
26
  {
27
+ private static final long serialVersionUID = 1L;
27
28
 
28
29
  public
29
30
  XmlProcessingInstruction(Ruby ruby, RubyClass klazz)
@@ -57,6 +57,7 @@ import nokogiri.internals.ReaderNode.TextNode;
57
57
  @JRubyClass(name = "Nokogiri::XML::Reader")
58
58
  public class XmlReader extends RubyObject
59
59
  {
60
+ private static final long serialVersionUID = 1L;
60
61
 
61
62
  private static final int XML_TEXTREADER_MODE_INITIAL = 0;
62
63
  private static final int XML_TEXTREADER_MODE_INTERACTIVE = 1;
@@ -224,7 +225,7 @@ public class XmlReader extends RubyObject
224
225
 
225
226
  Options options;
226
227
  if (args.length > 3) {
227
- options = new ParserContext.Options((Long)args[3].toJava(Long.class));
228
+ options = new ParserContext.Options(args[3].toJava(Long.class));
228
229
  } else {
229
230
  // use the default options RECOVER | NONET
230
231
  options = new ParserContext.Options(2048 | 1);
@@ -255,7 +256,7 @@ public class XmlReader extends RubyObject
255
256
 
256
257
  Options options;
257
258
  if (args.length > 3) {
258
- options = new ParserContext.Options((Long)args[3].toJava(Long.class));
259
+ options = new ParserContext.Options(args[3].toJava(Long.class));
259
260
  } else {
260
261
  // use the default options RECOVER | NONET
261
262
  options = new ParserContext.Options(2048 | 1);
@@ -403,7 +404,7 @@ public class XmlReader extends RubyObject
403
404
  final ReaderNode currentNode = currentNode();
404
405
  if (currentNode == null) { return runtime.getNil(); }
405
406
  if (currentNode.isError()) {
406
- RubyArray errors = (RubyArray) getInstanceVariable("@errors");
407
+ RubyArray<?> errors = (RubyArray) getInstanceVariable("@errors");
407
408
  IRubyObject error = currentNode.toSyntaxError();
408
409
  errors.append(error);
409
410
  setInstanceVariable("@errors", errors);
@@ -38,6 +38,7 @@ import org.xml.sax.SAXException;
38
38
  @JRubyClass(name = "Nokogiri::XML::RelaxNG", parent = "Nokogiri::XML::Schema")
39
39
  public class XmlRelaxng extends XmlSchema
40
40
  {
41
+ private static final long serialVersionUID = 1L;
41
42
  private Verifier verifier;
42
43
 
43
44
  public
@@ -28,6 +28,7 @@ import static org.jruby.runtime.Helpers.invoke;
28
28
  @JRubyClass(name = "Nokogiri::XML::SAX::ParserContext")
29
29
  public class XmlSaxParserContext extends ParserContext
30
30
  {
31
+ private static final long serialVersionUID = 1L;
31
32
 
32
33
  protected static final String FEATURE_NAMESPACES =
33
34
  "http://xml.org/sax/features/namespaces";
@@ -29,6 +29,8 @@ import static org.jruby.runtime.Helpers.invoke;
29
29
  @JRubyClass(name = "Nokogiri::XML::SAX::PushParser")
30
30
  public class XmlSaxPushParser extends RubyObject
31
31
  {
32
+ private static final long serialVersionUID = 1L;
33
+
32
34
  ParserContext.Options options;
33
35
  IRubyObject saxParser;
34
36
 
@@ -45,6 +47,7 @@ public class XmlSaxPushParser extends RubyObject
45
47
  super(ruby, rubyClass);
46
48
  }
47
49
 
50
+ @SuppressWarnings("deprecation")
48
51
  @Override
49
52
  public void
50
53
  finalize()
@@ -50,6 +50,8 @@ import org.xml.sax.SAXParseException;
50
50
  @JRubyClass(name = "Nokogiri::XML::Schema")
51
51
  public class XmlSchema extends RubyObject
52
52
  {
53
+ private static final long serialVersionUID = 1L;
54
+
53
55
  private Validator validator;
54
56
 
55
57
  public
@@ -149,7 +151,7 @@ public class XmlSchema extends RubyObject
149
151
 
150
152
  XmlDocument doc = ((XmlDocument)((XmlNode) document).document(context));
151
153
 
152
- RubyArray errors = (RubyArray) doc.getInstanceVariable("@errors");
154
+ RubyArray<?> errors = (RubyArray) doc.getInstanceVariable("@errors");
153
155
  if (!errors.isEmpty()) {
154
156
  throw((XmlSyntaxError) errors.first()).toThrowable();
155
157
  }
@@ -212,7 +214,7 @@ public class XmlSchema extends RubyObject
212
214
  IRubyObject
213
215
  validate_document_or_file(ThreadContext context, XmlDocument xmlDocument)
214
216
  {
215
- RubyArray errors = (RubyArray) this.getInstanceVariable("@errors");
217
+ RubyArray<?> errors = (RubyArray) this.getInstanceVariable("@errors");
216
218
  ErrorHandler errorHandler = new SchemaErrorHandler(context.runtime, errors);
217
219
  setErrorHandler(errorHandler);
218
220
 
@@ -21,6 +21,7 @@ import org.xml.sax.SAXParseException;
21
21
  @JRubyClass(name = "Nokogiri::XML::SyntaxError", parent = "Nokogiri::SyntaxError")
22
22
  public class XmlSyntaxError extends RubyException
23
23
  {
24
+ private static final long serialVersionUID = 1L;
24
25
 
25
26
  private Exception exception;
26
27
  private boolean messageSet; // whether a custom error message was set
@@ -25,6 +25,7 @@ import org.w3c.dom.Text;
25
25
  @JRubyClass(name = "Nokogiri::XML::Text", parent = "Nokogiri::XML::CharacterData")
26
26
  public class XmlText extends XmlNode
27
27
  {
28
+ private static final long serialVersionUID = 1L;
28
29
 
29
30
  private static final ByteList TEXT = ByteList.create("text");
30
31
  static { TEXT.setEncoding(USASCIIEncoding.INSTANCE); }
@@ -39,6 +39,8 @@ import static nokogiri.internals.NokogiriHelpers.nodeListToRubyArray;
39
39
  @JRubyClass(name = "Nokogiri::XML::XPathContext")
40
40
  public class XmlXpathContext extends RubyObject
41
41
  {
42
+ private static final long serialVersionUID = 1L;
43
+
42
44
  static
43
45
  {
44
46
  final String DTMManager = "org.apache.xml.dtm.DTMManager";
@@ -9,6 +9,7 @@ import java.io.PipedReader;
9
9
  import java.io.PipedWriter;
10
10
  import java.io.StringReader;
11
11
  import java.util.Set;
12
+ import java.util.Map;
12
13
  import java.util.regex.Matcher;
13
14
  import java.util.regex.Pattern;
14
15
 
@@ -22,8 +23,10 @@ import javax.xml.transform.dom.DOMSource;
22
23
  import javax.xml.transform.stream.StreamResult;
23
24
  import javax.xml.transform.stream.StreamSource;
24
25
 
25
- import org.apache.xalan.transformer.TransformerImpl;
26
26
  import org.apache.xml.serializer.SerializationHandler;
27
+ import org.apache.xml.serializer.Serializer;
28
+ import org.apache.xml.serializer.SerializerFactory;
29
+
27
30
  import org.jruby.Ruby;
28
31
  import org.jruby.RubyArray;
29
32
  import org.jruby.RubyClass;
@@ -48,6 +51,7 @@ import nokogiri.internals.NokogiriXsltErrorListener;
48
51
  @JRubyClass(name = "Nokogiri::XSLT::Stylesheet")
49
52
  public class XsltStylesheet extends RubyObject
50
53
  {
54
+ private static final long serialVersionUID = 1L;
51
55
 
52
56
  private TransformerFactory factory = null;
53
57
  private Templates sheet = null;
@@ -86,18 +90,17 @@ public class XsltStylesheet extends RubyObject
86
90
  }
87
91
  }
88
92
 
93
+ @SuppressWarnings("unchecked")
89
94
  private void
90
95
  setHashParameters(Transformer transformer, RubyHash hash)
91
96
  {
92
- Set<String> keys = hash.keySet();
93
- for (String key : keys) {
94
- String value = (String)hash.get(key);
95
- transformer.setParameter(key, unparseValue(value));
97
+ for (Map.Entry<Object, Object> entry : (Set<Map.Entry<Object, Object>>)hash.entrySet()) {
98
+ transformer.setParameter((String)entry.getKey(), unparseValue((String)entry.getValue()));
96
99
  }
97
100
  }
98
101
 
99
102
  private void
100
- setArrayParameters(Transformer transformer, Ruby runtime, RubyArray params)
103
+ setArrayParameters(Transformer transformer, Ruby runtime, RubyArray<?> params)
101
104
  {
102
105
  int limit = params.getLength();
103
106
  if (limit % 2 == 1) { limit--; }
@@ -168,7 +171,7 @@ public class XsltStylesheet extends RubyObject
168
171
  ensureDocumentHasNoError(ThreadContext context, XmlDocument xmlDoc)
169
172
  {
170
173
  Ruby runtime = context.getRuntime();
171
- RubyArray errors_of_xmlDoc = (RubyArray) xmlDoc.getInstanceVariable("@errors");
174
+ RubyArray<?> errors_of_xmlDoc = (RubyArray) xmlDoc.getInstanceVariable("@errors");
172
175
  if (!errors_of_xmlDoc.isEmpty()) {
173
176
  throw runtime.newRuntimeError(errors_of_xmlDoc.first().asString().asJavaString());
174
177
  }
@@ -176,14 +179,14 @@ public class XsltStylesheet extends RubyObject
176
179
 
177
180
  @JRubyMethod
178
181
  public IRubyObject
179
- serialize(ThreadContext context, IRubyObject doc) throws IOException, TransformerException
182
+ serialize(ThreadContext context, IRubyObject doc) throws IOException
180
183
  {
181
184
  XmlDocument xmlDoc = (XmlDocument) doc;
182
- TransformerImpl transformer = (TransformerImpl) this.sheet.newTransformer();
183
185
  ByteArrayOutputStream writer = new ByteArrayOutputStream();
184
- StreamResult streamResult = new StreamResult(writer);
185
- SerializationHandler serializationHandler = transformer.createSerializationHandler(streamResult);
186
- serializationHandler.serialize(xmlDoc.getNode());
186
+
187
+ Serializer serializer = SerializerFactory.getSerializer(this.sheet.getOutputProperties());
188
+ serializer.setOutputStream(writer);
189
+ ((SerializationHandler) serializer).serialize(xmlDoc.getNode());
187
190
  return context.getRuntime().newString(writer.toString());
188
191
  }
189
192
 
@@ -329,7 +332,7 @@ public class XsltStylesheet extends RubyObject
329
332
  RubyClass xmlDocumentClass = getNokogiriClass(runtime, "Nokogiri::XML::Document");
330
333
  XmlDocument xmlDocument = (XmlDocument) Helpers.invoke(context, xmlDocumentClass, "parse", args);
331
334
  if (((Document)xmlDocument.getNode()).getDocumentElement() == null) {
332
- RubyArray errors = (RubyArray) xmlDocument.getInstanceVariable("@errors");
335
+ RubyArray<?> errors = (RubyArray) xmlDocument.getInstanceVariable("@errors");
333
336
  Helpers.invoke(context, errors, "<<", args[0]);
334
337
  }
335
338
  return xmlDocument;
@@ -15,8 +15,8 @@ import org.apache.xerces.xni.XMLAttributes;
15
15
  import org.apache.xerces.xni.XNIException;
16
16
  import org.apache.xerces.xni.parser.XMLDocumentFilter;
17
17
  import org.apache.xerces.xni.parser.XMLParserConfiguration;
18
- import org.cyberneko.html.HTMLConfiguration;
19
- import org.cyberneko.html.filters.DefaultFilter;
18
+ import net.sourceforge.htmlunit.cyberneko.HTMLConfiguration;
19
+ import net.sourceforge.htmlunit.cyberneko.filters.DefaultFilter;
20
20
  import org.jruby.Ruby;
21
21
  import org.jruby.RubyClass;
22
22
  import org.jruby.runtime.ThreadContext;
@@ -36,6 +36,7 @@ import org.w3c.dom.NodeList;
36
36
  */
37
37
  public class HtmlDomParserContext extends XmlDomParserContext
38
38
  {
39
+ private static final long serialVersionUID = 1L;
39
40
 
40
41
  public
41
42
  HtmlDomParserContext(Ruby runtime, IRubyObject options)
@@ -114,9 +114,9 @@ public class NokogiriHandler extends DefaultHandler2 implements XmlDeclHandler
114
114
  final ThreadContext context = runtime.getCurrentContext();
115
115
 
116
116
  // for attributes other than namespace attrs
117
- RubyArray rubyAttr = RubyArray.newArray(runtime);
117
+ RubyArray<?> rubyAttr = RubyArray.newArray(runtime);
118
118
  // for namespace defining attributes
119
- RubyArray rubyNSAttr = RubyArray.newArray(runtime);
119
+ RubyArray<?> rubyNSAttr = RubyArray.newArray(runtime);
120
120
 
121
121
  boolean fromFragmentHandler = false; // isFromFragmentHandler();
122
122
 
@@ -645,10 +645,10 @@ public class NokogiriHelpers
645
645
  return result;
646
646
  }
647
647
 
648
- public static RubyArray
648
+ public static RubyArray<?>
649
649
  nodeArrayToRubyArray(Ruby ruby, Node[] nodes)
650
650
  {
651
- RubyArray n = RubyArray.newArray(ruby, nodes.length);
651
+ RubyArray<?> n = RubyArray.newArray(ruby, nodes.length);
652
652
  for (int i = 0; i < nodes.length; i++) {
653
653
  n.append(NokogiriHelpers.getCachedNodeOrCreate(ruby, nodes[i]));
654
654
  }
@@ -754,10 +754,9 @@ public class NokogiriHelpers
754
754
  else if (NokogiriHelpers.EUC_JP.compareTo(encoding) == 0) { opt = _Ew; }
755
755
  else { opt = _Ww; } // should not come here. should be treated before this method.
756
756
 
757
- Class nkfClass;
757
+ Class<?> nkfClass;
758
758
  try {
759
- // JRuby 1.7 and later
760
- nkfClass = runtime.getClassLoader().loadClass("org.jruby.ext.nkf.RubyNKF");
759
+ nkfClass = Ruby.getClassLoader().loadClass("org.jruby.ext.nkf.RubyNKF");
761
760
  } catch (ClassNotFoundException e1) {
762
761
  return str;
763
762
  }
@@ -52,7 +52,7 @@ public class NokogiriXPathFunction implements XPathFunction
52
52
  }
53
53
 
54
54
  public Object
55
- evaluate(List args) throws XPathFunctionException
55
+ evaluate(List<?> args) throws XPathFunctionException
56
56
  {
57
57
  if (args.size() != this.arity) {
58
58
  throw new XPathFunctionException("arity does not match");
@@ -76,7 +76,7 @@ public class NokogiriXPathFunction implements XPathFunction
76
76
  }
77
77
 
78
78
  private static IRubyObject[]
79
- fromObjectToRubyArgs(final Ruby runtime, List args)
79
+ fromObjectToRubyArgs(final Ruby runtime, List<?> args)
80
80
  {
81
81
  IRubyObject[] newArgs = new IRubyObject[args.size()];
82
82
  for (int i = 0; i < args.size(); i++) {
@@ -114,7 +114,7 @@ public class NokogiriXPathFunction implements XPathFunction
114
114
  }
115
115
 
116
116
  private static boolean
117
- builtinCssClass(List args) throws XPathFunctionException
117
+ builtinCssClass(List<?> args) throws XPathFunctionException
118
118
  {
119
119
  if (args.size() != 2) {
120
120
  throw new XPathFunctionException("builtin function nokogiri:css-class takes two arguments");
@@ -28,6 +28,8 @@ import org.xml.sax.InputSource;
28
28
  */
29
29
  public abstract class ParserContext extends RubyObject
30
30
  {
31
+ private static final long serialVersionUID = 1L;
32
+
31
33
  protected InputSource source = null;
32
34
  protected IRubyObject detected_encoding = null;
33
35
  protected int stringDataSize = -1;
@@ -91,7 +91,7 @@ public abstract class ReaderNode
91
91
  public IRubyObject
92
92
  getAttributesNodes()
93
93
  {
94
- RubyArray array = RubyArray.newArray(ruby);
94
+ RubyArray<?> array = RubyArray.newArray(ruby);
95
95
  if (attributeList != null && attributeList.length > 0) {
96
96
  if (document == null) {
97
97
  document = XmlDocument.createNewDocument(ruby);
@@ -12,7 +12,7 @@ import java.util.*;
12
12
  import java.util.regex.Matcher;
13
13
  import java.util.regex.Pattern;
14
14
 
15
- import org.cyberneko.html.HTMLElements;
15
+ import net.sourceforge.htmlunit.cyberneko.HTMLElements;
16
16
  import org.w3c.dom.Attr;
17
17
  import org.w3c.dom.CDATASection;
18
18
  import org.w3c.dom.Comment;
@@ -81,6 +81,8 @@ public class SaveContextVisitor
81
81
  public static final int SUBSETS = 8;
82
82
  public static final int EXCLUSIVE = 16;
83
83
 
84
+ private static final HTMLElements htmlElements_ = new HTMLElements();
85
+
84
86
  public
85
87
  SaveContextVisitor(int options, CharSequence indent, String encoding, boolean htmlDoc, boolean fragment,
86
88
  int canonicalOpts)
@@ -498,7 +500,7 @@ public class SaveContextVisitor
498
500
  private boolean
499
501
  isEmpty(String name)
500
502
  {
501
- HTMLElements.Element element = HTMLElements.getElement(name);
503
+ HTMLElements.Element element = htmlElements_.getElement(name);
502
504
  return element.isEmpty();
503
505
  }
504
506
 
@@ -20,10 +20,10 @@ public class SchemaErrorHandler implements ErrorHandler
20
20
  {
21
21
 
22
22
  private final Ruby runtime;
23
- final RubyArray errors;
23
+ final RubyArray<?> errors;
24
24
 
25
25
  public
26
- SchemaErrorHandler(Ruby ruby, RubyArray array)
26
+ SchemaErrorHandler(Ruby ruby, RubyArray<?> array)
27
27
  {
28
28
  this.runtime = ruby;
29
29
  this.errors = array;
@@ -30,6 +30,7 @@ import static nokogiri.internals.NokogiriHelpers.isBlank;
30
30
  */
31
31
  public class XmlDomParserContext extends ParserContext
32
32
  {
33
+ private static final long serialVersionUID = 1L;
33
34
 
34
35
  protected static final String FEATURE_LOAD_EXTERNAL_DTD =
35
36
  "http://apache.org/xml/features/nonvalidating/load-external-dtd";
@@ -150,7 +151,7 @@ public class XmlDomParserContext extends ParserContext
150
151
  }
151
152
 
152
153
 
153
- public static RubyArray
154
+ public static RubyArray<?>
154
155
  mapErrors(ThreadContext context, NokogiriErrorHandler errorHandler)
155
156
  {
156
157
  final Ruby runtime = context.runtime;
@@ -87,6 +87,7 @@ public class Canonicalizer
87
87
  * @param algorithmURI
88
88
  * @throws InvalidCanonicalizerException
89
89
  */
90
+ @SuppressWarnings("deprecation")
90
91
  private
91
92
  Canonicalizer(String algorithmURI) throws CanonicalizationException
92
93
  {
@@ -580,7 +580,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
580
580
 
581
581
  int identity = makeNodeIdentity(nodeHandle);
582
582
 
583
- return (Node) m_nodes.get(identity);
583
+ return m_nodes.get(identity);
584
584
  }
585
585
 
586
586
  /**
@@ -593,7 +593,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
593
593
  protected Node
594
594
  lookupNode(int nodeIdentity)
595
595
  {
596
- return (Node) m_nodes.get(nodeIdentity);
596
+ return m_nodes.get(nodeIdentity);
597
597
  }
598
598
 
599
599
  /**
@@ -987,7 +987,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
987
987
  // {
988
988
  int id = makeNodeIdentity(nodeHandle);
989
989
  if (NULL == id) { return null; }
990
- Node newnode = (Node)m_nodes.get(id);
990
+ Node newnode = m_nodes.get(id);
991
991
  String newname = newnode.getLocalName();
992
992
  if (null == newname) {
993
993
  // XSLT treats PIs, and possibly other things, as having QNames.
@@ -1102,7 +1102,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
1102
1102
  // {
1103
1103
  int id = makeNodeIdentity(nodeHandle);
1104
1104
  if (id == NULL) { return null; }
1105
- Node node = (Node)m_nodes.get(id);
1105
+ Node node = m_nodes.get(id);
1106
1106
  return node.getNamespaceURI();
1107
1107
  // }
1108
1108
  // else
@@ -1608,6 +1608,7 @@ public class DOM2DTM extends DTMDefaultBaseIterators
1608
1608
  * @param node Node whose subtree is to be walked, gathering the
1609
1609
  * contents of all Text or CDATASection nodes.
1610
1610
  */
1611
+ @SuppressWarnings("fallthrough")
1611
1612
  protected static void
1612
1613
  dispatchNodeData(Node node,
1613
1614
  org.xml.sax.ContentHandler ch,