Home
Categories
Dictionary
Download
Project Details
Changes Log
What Links Here
How To
Syntax
FAQ
License

DocGenerator API: importing articles



Several methods allow to import articles from XML files. it is possible to:

Import an article

The DocGeneratorAPI.importArticle(URL) and DocGeneratorAPI.importArticle(File) will import an article defined in an XML file in the wiki.

For example:
  DocGeneratorAPI api = new DocGeneratorAPI();
  api.createModel();
         
  XMLArticle article = api.createArticle("an article about birds");
      
  try {
     File theXMLFile = ...
     XMLArticle importedArticle = api.importArticle(theXMLFile);
  } catch (DocGeneratorAPIException e) {
     System.err.println(e.getMessage());
  }

Include an article

The DocGeneratorAPI.includeArticle(XMLArticle, URL, boolean) and DocGeneratorAPI.includeArticle(XMLArticle, File, boolean) will include an article defined in an XML file in another article. The second argument specifies if the levels of the titles in the included article must be kept.

Contrary to the usage of templates in regular wiki generation, the included article will never be present as a regular article in the wiki. It will not appear in the dictionary for example.


For example:
  DocGeneratorAPI api = new DocGeneratorAPI();
  api.createModel();
         
  XMLArticle article = api.createArticle("an article about birds");
      
  try {
     File theXMLFile = ...
     File includedArticle = api.article(article, theXMLFile, false);
  } catch (DocGeneratorAPIException e) {
     System.err.println(e.getMessage());
  }      

Import an Image definition file

The DocGeneratorAPI.importImageDefinition(URL) and DocGeneratorAPI.importImageDefinition(File) will import the images from an Image definition file in the wiki.

The ids of the imported image definitions will be usable in the following method: For example:
   DocGeneratorAPI api = new DocGeneratorAPI();
   api.createModel();
         
   XMLArticle article = api.createArticle("an article about birds");
      
   // import the images
   try {
      File theXMLFile = ...
      api.importImageDefinition(theXMLFile);
   } catch (DocGeneratorAPIException e) {
      System.err.println(e.getMessage());
   }     
   // use one of the images
   api.addImage(article, "myImageID", true);  

See also


Categories: api

docJGenerator Copyright (c) 2016-2023 Herve Girod. All rights reserved.