public AbstractSiteMap parseSiteMap(String contentType,byte[] content,URL url) throws UnknownFormatException, IOException {
  MediaType mediaType=MediaType.parse(contentType);
  while (mediaType != null && !mediaType.equals(MediaType.OCTET_STREAM)) {
    if (XML_MEDIA_TYPES.contains(mediaType)) {
      return processXml(url,content);
    }
 else     if (TEXT_MEDIA_TYPES.contains(mediaType)) {
      return processText(url.toString(),content);
    }
 else     if (GZ_MEDIA_TYPES.contains(mediaType)) {
      return processGzip(url,content);
    }
 else {
      mediaType=MEDIA_TYPE_REGISTRY.getSupertype(mediaType);
      return parseSiteMap(mediaType.toString(),content,url);
    }
  }
  throw new UnknownFormatException("Can't parse a sitemap with the MediaType of: " + contentType + " (at: "+ url+ ")");
}

public AbstractSiteMap parseSiteMap ( String contentType , byte [ ] content , URL url ) throws UnknownFormatException , IOException { MediaType mediaType = MediaType . parse ( contentType ) ; while ( mediaType != null && ! mediaType . equals ( MediaType . OCTET_STREAM ) ) { if ( XML_MEDIA_TYPES . contains ( mediaType ) ) { return processXml ( url , content ) ; } else if ( TEXT_MEDIA_TYPES . contains ( mediaType ) ) { return processText ( url . toString ( ) , content ) ; } else if ( GZ_MEDIA_TYPES . contains ( mediaType ) ) { return processGzip ( url , content ) ; } else { mediaType = MEDIA_TYPE_REGISTRY . getSupertype ( mediaType ) ; return parseSiteMap ( mediaType . toString ( ) , content , url ) ; } } throw new UnknownFormatException ( "Can't parse a sitemap with the MediaType of: " + contentType + " (at: " + url + ")" ) ; }
parse a sitemap , given the mime type , the content bytes , and the url . note that contenttype is assumed to be correct ; in general it is more robust to use the method that doesn ' t take a contenttype , but instead detects this using tika .
