public boolean parseXmlFlash ( Path ttmlFilePath ) { boolean ret ; try { final DocumentBuilderFactory dbf = DocumentBuilderFactory . newInstance ( ) ; dbf . setNamespaceAware ( true ) ; final DocumentBuilder db = dbf . newDocumentBuilder ( ) ; doc = db . parse ( ttmlFilePath . toFile ( ) ) ; //Check that we have TTML v1.0 file as we have tested only them... final NodeList metaData = doc . getElementsByTagName ( "tt" ) ; final NodeList colorNote = doc . getElementsByTagName ( "style" ) ; if ( metaData != null ) { final Node node = metaData . item ( 0 ) ; if ( node . hasAttributes ( ) ) { // retrieve the begin and end attributes... final NamedNodeMap attrMap = node . getAttributes ( ) ; final Node xmlns = attrMap . getNamedItem ( "xmlns" ) ; if ( xmlns != null ) { final String s = xmlns . getNodeValue ( ) ; if ( ! s . equals ( "http://www.w3.org/2006/04/ttaf1" ) && ! s . equals ( "http://www.w3.org/ns/ttml" ) ) { throw new Exception ( "Unknown TTML file version" ) ; } } } else { throw new Exception ( "Unknown File Format" ) ; } } else { throw new Exception ( "Unknown File Format" ) ; } if ( colorNote != null ) { if ( colorNote . getLength ( ) == 0 ) { this . color = "#FFFFFF" ; } else { final Node node = colorNote . item ( 0 ) ; if ( node . hasAttributes ( ) ) { // retrieve the begin and end attributes... final NamedNodeMap attrMap = node . getAttributes ( ) ; final Node col = attrMap . getNamedItem ( "tts:color" ) ; if ( col != null ) { if ( ! col . getNodeValue ( ) . isEmpty ( ) ) { this . color = col . getNodeValue ( ) ; } } } else { throw new Exception ( "Unknown File Format" ) ; } } } else { throw new Exception ( "Unknown File Format" ) ; } buildFilmListFlash ( ) ; ret = true ; } catch ( Exception ex ) { //Log.errorLog(46231470, ex, "File: " + ttmlFilePath); Log . errorLog ( 46231470 , new String [ ] { ex . getLocalizedMessage ( ) , "File: " + ttmlFilePath } ) ; ret = false ; } return ret ; }
Parse the XML Subtitle File for Flash Player into internal representation .