Ejemplo n.º 1
0
 /**
  * Get the first topic id.
  *
  * @param path file path
  * @param dir file dir
  * @param useCatalog whether use catalog file for validation
  * @return topic id
  */
 public static String getFirstTopicId(final URI path, final File dir, final boolean useCatalog) {
   if (path == null && dir == null) {
     return null;
   }
   final DITAOTLogger logger = new DITAOTJavaLogger();
   final StringBuilder firstTopicId = new StringBuilder();
   final TopicIdParser parser = new TopicIdParser(firstTopicId);
   try {
     final XMLReader reader = XMLUtils.getXMLReader();
     reader.setContentHandler(parser);
     if (useCatalog) {
       reader.setEntityResolver(CatalogUtils.getCatalogResolver());
     }
     reader.parse(dir.toURI().resolve(path).toString());
   } catch (final Exception e) {
     logger.error(e.getMessage(), e);
   }
   return firstTopicId.toString();
 }