diff --git a/library/src/androidTest/assets/ttml/namespace_confusion.xml b/library/src/androidTest/assets/ttml/namespace_confusion.xml
new file mode 100644
index 0000000000..5b9025cd94
--- /dev/null
+++ b/library/src/androidTest/assets/ttml/namespace_confusion.xml
@@ -0,0 +1,17 @@
+
+
+
+
+
+
diff --git a/library/src/androidTest/assets/ttml/namespace_not_declared.xml b/library/src/androidTest/assets/ttml/namespace_not_declared.xml
new file mode 100644
index 0000000000..25e8369a34
--- /dev/null
+++ b/library/src/androidTest/assets/ttml/namespace_not_declared.xml
@@ -0,0 +1,13 @@
+
+
+
+
+
+
diff --git a/library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlParserTest.java b/library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlParserTest.java
index 6236bda5c0..804dca8b15 100644
--- a/library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlParserTest.java
+++ b/library/src/androidTest/java/com/google/android/exoplayer/text/ttml/TtmlParserTest.java
@@ -45,6 +45,10 @@ public final class TtmlParserTest extends InstrumentationTestCase {
"ttml/no_underline_linethrough.xml";
private static final String INSTANCE_CREATION_TTML_FILE =
"ttml/instance_creation.xml";
+ private static final String NAMESPACE_CONFUSION_TTML_FILE =
+ "ttml/namespace_confusion.xml";
+ private static final String NAMESPACE_NOT_DECLARED_TTML_FILE =
+ "ttml/namespace_not_declared.xml";
public void testInlineAttributes() throws IOException {
TtmlSubtitle subtitle = getSubtitle(INLINE_ATTRIBUTES_TTML_FILE);
@@ -331,6 +335,44 @@ public final class TtmlParserTest extends InstrumentationTestCase {
assertNotSame(thirdP.style.getInheritableStyle(), thirdSpan.style);
}
+ public void testNamspaceConfusionDoesNotHurt() throws IOException {
+ TtmlSubtitle subtitle = getSubtitle(NAMESPACE_CONFUSION_TTML_FILE);
+ assertEquals(2, subtitle.getEventTimeCount());
+
+ TtmlNode root = subtitle.getRoot();
+ TtmlNode body = queryChildrenForTag(root, TtmlNode.TAG_BODY, 0);
+ TtmlNode div = queryChildrenForTag(body, TtmlNode.TAG_DIV, 0);
+ TtmlStyle style = queryChildrenForTag(div, TtmlNode.TAG_P, 0).style;
+
+ assertNotNull(style);
+ assertEquals(Color.BLACK, style.getBackgroundColor());
+ assertEquals(Color.YELLOW, style.getColor());
+ assertEquals(TtmlStyle.STYLE_ITALIC, style.getStyle());
+ assertEquals("sansSerif", style.getFontFamily());
+ assertFalse(style.isUnderline());
+ assertTrue(style.isLinethrough());
+
+ }
+
+ public void testNamespaceNotDeclared() throws IOException {
+ TtmlSubtitle subtitle = getSubtitle(NAMESPACE_NOT_DECLARED_TTML_FILE);
+ assertEquals(2, subtitle.getEventTimeCount());
+
+ TtmlNode root = subtitle.getRoot();
+ TtmlNode body = queryChildrenForTag(root, TtmlNode.TAG_BODY, 0);
+ TtmlNode div = queryChildrenForTag(body, TtmlNode.TAG_DIV, 0);
+ TtmlStyle style = queryChildrenForTag(div, TtmlNode.TAG_P, 0).style;
+
+ assertNotNull(style);
+ assertEquals(Color.BLACK, style.getBackgroundColor());
+ assertEquals(Color.YELLOW, style.getColor());
+ assertEquals(TtmlStyle.STYLE_ITALIC, style.getStyle());
+ assertEquals("sansSerif", style.getFontFamily());
+ assertFalse(style.isUnderline());
+ assertTrue(style.isLinethrough());
+
+ }
+
private TtmlNode queryChildrenForTag(TtmlNode node, String tag, int pos) {
int count = 0;
for (int i = 0; i < node.getChildCount(); i++) {
diff --git a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
index 1a7617a577..2379eed5bf 100644
--- a/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
+++ b/library/src/main/java/com/google/android/exoplayer/text/ttml/TtmlParser.java
@@ -194,7 +194,6 @@ public final class TtmlParser implements SubtitleParser {
for (int i = 0; i < attributeCount; i++) {
String attributeName = parser.getAttributeName(i);
String attributeValue = parser.getAttributeValue(i);
- // TODO: check if it is safe to remove the namespace prefix
switch (ParserUtil.removeNamespacePrefix(attributeName)) {
case TtmlNode.ATTR_ID:
if (TtmlNode.TAG_STYLE.equals(parser.getName())) {