AttributesCollectorUsingSaxTest.java 文件源码

java
阅读 24 收藏 0 点赞 0 评论 0

项目:oxygen-dita-translation-package-builder 作者:
/**
 * <p><b>Description:</b> Test the conrefs are handled by the SAXParser.</p>
 * <p><b>Bug ID:</b> #15</p>
 *
 * @author adrian_sorop
 *
 * @throws Exception
 */
public void testSaxParserConref() throws Exception {
  File ditaFile = new File(TestUtil.getPath("issue-15_1/topics"),"topic2.dita");
  assertTrue("UNABLE TO LOAD FILE", ditaFile.exists());
  URL url = URLUtil.correct(ditaFile);

  SAXParserFactory factory = SAXParserFactory.newInstance();
  // Ignore the DTD declaration
  factory.setValidating(false);
  factory.setFeature("http://apache.org/xml/features/nonvalidating/load-external-dtd", false);
  factory.setFeature("http://xml.org/sax/features/validation", false);

  SAXParser parser = factory.newSAXParser();
  SaxContentHandler handler= new SaxContentHandler(url);
  parser.parse(ditaFile, handler);

  List<ReferencedResource> referredFiles = new ArrayList<ReferencedResource>();
  referredFiles.addAll(handler.getDitaMapHrefs());

  assertEquals("Two files should have been referred.", 2, referredFiles.size());

  assertTrue("Should be a content reference to topicConref.dita but was" + referredFiles.get(1).getLocation(), 
      referredFiles.get(1).getLocation().toString().contains("issue-15_1/topics/topicConref.dita"));
  assertTrue("Should be a xref to topic3.dita", 
      referredFiles.get(0).getLocation().toString().contains("issue-15_1/topics/topic3.dita"));
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号