return RSS_2_0_Parser.getInstance().parse(cBuilder, root);
} else if (rssVersion.indexOf("2.0") >= 0 || rssVersion.equals("2")) {
LOGGER.info("Channel uses RSS root element (Version 2.0).");
return RSS_2_0_Parser.getInstance().parse(cBuilder, root);
} else {
throw new UnsupportedFormatException("Unsupported RSS version [" +
rssVersion + "].");
}
} else if (rootElement.indexOf("rdf") >= 0) {
return RSS_1_0_Parser.getInstance().parse(cBuilder, root);
} else if (rootElement.indexOf("feed") >= 0) {
Attribute versionAttr = root.getAttribute("version");
Namespace namespace = ParserUtils.getDefaultNS(root);
if (versionAttr != null) {
String feedVersion = versionAttr.getValue();
if (feedVersion.indexOf("0.1") >= 0 || feedVersion.indexOf("0.2") >= 0) {
LOGGER.info("Channel uses feed root element (Version " + feedVersion + ").");
LOGGER.warn("This atom version is not really supported yet, assume Atom 0.3 format");
return Atom_0_3_Parser.getInstance().parse(cBuilder, root);
} else if (feedVersion.indexOf("0.3") >= 0) {
LOGGER.info("Channel uses feed root element (Version 0.3).");
return Atom_0_3_Parser.getInstance().parse(cBuilder, root);
}
} else if (namespace != null && namespace.getURI() != null) {
if ( !namespace.getURI().equals("http://www.w3.org/2005/Atom")) {
LOGGER.warn("Channel uses unknown namespace in feed root element, assume Atom 1.0 format.");
} else {
LOGGER.info("Channel uses feed root element (Atom 1.0 format).");
}
return Atom_1_0_Parser.getInstance().parse(cBuilder, root);
}
}
// did not match anything
throw new UnsupportedFormatException("Unsupported root element [" +
rootElement + "].");
}