diff --git a/rome/src/main/java/com/rometools/rome/io/impl/RSS20Parser.java b/rome/src/main/java/com/rometools/rome/io/impl/RSS20Parser.java index b90c4e6..56bf541 100644 --- a/rome/src/main/java/com/rometools/rome/io/impl/RSS20Parser.java +++ b/rome/src/main/java/com/rometools/rome/io/impl/RSS20Parser.java @@ -51,7 +51,8 @@ public class RSS20Parser extends RSS094Parser { @Override public boolean isMyType(final Document document) { - return rootElementMatches(document) && versionMatches(document); + return rootElementMatches(document) + && (versionMatches(document) || versionAbsent(document)); } private boolean rootElementMatches(final Document document) { @@ -63,4 +64,8 @@ public class RSS20Parser extends RSS094Parser { return (version != null) && version.getValue().trim().startsWith(getRSSVersion()); } + + private boolean versionAbsent(final Document document) { + return document.getRootElement().getAttribute("version") == null; + } } diff --git a/rome/src/test/java/com/rometools/rome/io/impl/RSS20ParserTest.java b/rome/src/test/java/com/rometools/rome/io/impl/RSS20ParserTest.java index fff46c7..4493de2 100644 --- a/rome/src/test/java/com/rometools/rome/io/impl/RSS20ParserTest.java +++ b/rome/src/test/java/com/rometools/rome/io/impl/RSS20ParserTest.java @@ -44,4 +44,10 @@ public class RSS20ParserTest { document.setRootElement(new Element("rss").setAttribute("version", "2.0test")); assertTrue(parser.isMyType(document)); } + + @Test + public void testIsMyTypeVersionAbsent() { + document.setRootElement(new Element("rss")); + assertTrue(parser.isMyType(document)); + } }