code: private void buildColorMap() {
          final NodeList styleData = doc.getElementsByTagName("tt:style");
          for (int i = 0; i < styleData.getLength(); i++) {
              final Node subnode = styleData.item(i);
              if (subnode.hasAttributes()) {
                  final NamedNodeMap attrMap = subnode.getAttributes();
                  final Node idNode = attrMap.getNamedItem("xml:id");
                  final Node colorNode = attrMap.getNamedItem("tts:color");
                  if (idNode != null && colorNode != null) {
                      colorMap.put(idNode.getNodeValue(), colorNode.getNodeValue());
                  }
              }
          }
      }
docs: Build a map of used colors within the TTML file.