private static void doTasks(Node task) {

    NodeList subTasks = task.getChildNodes();

    List<Node> ontologyNodes = new LinkedList<Node>();

    for (int i = 0; i < subTasks.getLength(); i++) {
      Node childNode = subTasks.item(i);
      if (childNode.getNodeName().equals("task")) {
        doTasks(childNode);
      } else if (childNode.getNodeName().equals("ontology")) {
        ontologyNodes.add(childNode);
      }
    }

    final Node taskNameNode = task.getAttributes().getNamedItem("name");
    final String taskName = taskNameNode.getTextContent().trim();

    if (ontologyNodes.size() == 2) {
      // process the ontology pair

      System.out.println("Starting task '" + taskName + "'");
      RunTimer timer = new RunTimer().resetAndStart();
      processPair(taskName, ontologyNodes.get(0), ontologyNodes.get(1));
      timer.stop();
      System.out.println("Task done: " + timer);

      gc();

    } else {
      System.out.println("Do not know how to handle this task: '" + taskName + "'");
    }
  }
  private static OntModel loadOntology(String sourceOnt, String sourceURI) {
    System.out.println("\tLoading ontology: " + sourceOnt);

    RunTimer timer = new RunTimer().resetAndStart();

    OntModel sourceModel = ModelFactory.createOntologyModel(OntModelSpec.OWL_MEM, null);
    sourceModel.read(sourceURI, null, "RDF/XML");

    long sourceModelSize = sourceModel.size();

    timer.stop();

    System.out.println("\tLoaded " + sourceModelSize + " triples in " + timer);

    return sourceModel;
  }