Skip to content

armgit / nutch

Public Imported from GitHub
0

Apache Nutch is an extensible and scalable web crawler

NUTCH-715 - Subcollection plugin doesn't work with default subcollections.xml file. Contributed by Dmitry Lihachev

Sami Siren46a192a4b5a4
diff --git a/CHANGES.txt b/CHANGES.txt
index f98dcfa24..cf0270283 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -378,6 +378,9 @@ Release 1.0 - 2009-03-08
142. NUTCH-684 - Dedup support for Solr. (dogacan)
+143. NUTCH-715 - Subcollection plugin doesn't work with default
+ subcollections.xml file (Dmitry Lihachev via siren)
+
Release 0.9 - 2007-04-02
1. Changed log4j confiquration to log to stdout on commandline
diff --git a/src/java/org/apache/nutch/util/DomUtil.java b/src/java/org/apache/nutch/util/DomUtil.java
index f6026db57..e66e6ad3d 100644
--- a/src/java/org/apache/nutch/util/DomUtil.java
+++ b/src/java/org/apache/nutch/util/DomUtil.java
@@ -60,7 +60,11 @@ public class DomUtil {
input = new InputSource(is);
input.setEncoding("UTF-8");
parser.parse(input);
- element = (Element) parser.getDocument().getChildNodes().item(0);
+ int i = 0;
+ while (! (parser.getDocument().getChildNodes().item(i) instanceof Element)) {
+ i++;
+ }
+ element = (Element)parser.getDocument().getChildNodes().item(i);
} catch (FileNotFoundException e) {
e.printStackTrace(LogUtil.getWarnStream(LOG));
} catch (SAXException e) {
diff --git a/src/plugin/build.xml b/src/plugin/build.xml
index 66fd363eb..a301d61a0 100755
--- a/src/plugin/build.xml
+++ b/src/plugin/build.xml
@@ -112,6 +112,7 @@
<ant dir="parse-swf" target="test"/>
<ant dir="parse-zip" target="test"/>
<ant dir="query-url" target="test"/>
+ <ant dir="subcollection" target="test"/>
<ant dir="urlfilter-automaton" target="test"/>
<ant dir="urlfilter-domain" target="test" />
<ant dir="urlfilter-regex" target="test"/>
diff --git a/src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java b/src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java
index 5cbb80134..48a45b466 100644
--- a/src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java
+++ b/src/plugin/subcollection/src/test/org/apache/nutch/collection/TestSubcollection.java
@@ -49,6 +49,7 @@ public class TestSubcollection extends TestCase {
public void testInput(){
StringBuffer xml=new StringBuffer();
xml.append("<?xml version=\"1.0\" encoding=\"UTF-8\"?>");
+ xml.append("<!-- just a comment -->");
xml.append("<subcollections>");
xml.append("<subcollection>");
xml.append("<name>nutch collection</name>");