public static void removeMimeType(String mimeId) {
   Elements els = _root.getChildElements("mime-type");
   for (int i = 0; i < els.size(); i++)
     if (els.get(i).getAttribute("id").getValue().equals(mimeId)) {
       _root.removeChild(els.get(i));
       return;
     }
 }
Пример #2
0
 /**
  * Removes <Reify> elements recursively from a given element
  *
  * @param element Element to skip <Reify> elements in
  */
 private void removeReifyElements(Element element) {
   Elements children = element.getChildElements();
   for (int i = 0; i < children.size(); i++) {
     Element child = children.get(i);
     if (child.getLocalName().equals(tagNames.REIFY)) {
       element.removeChild(child);
     } else {
       removeReifyElements(child);
     }
   }
 }
Пример #3
0
  /**
   * Method to parse a Expr (Expresion)
   *
   * @param expr Element The XOM element that represents the Expr to be parsed.
   * @return Returns the data structure that represents the Expr in a way that can be used by the
   *     reasoning engine.
   * @throws ParseException Thrown if there is an error parsing the Expr.
   */
  private Term parseExpression(Element expr) throws ParseException {
    Elements children = expr.getChildElements();
    Element op = children.get(0);

    boolean foundOp = false;

    if (op.getLocalName().equals(tagNames.OP)) {
      foundOp = true;
    }

    Element fun = null;
    if (foundOp) {
      Elements funTag = op.getChildElements();
      fun = funTag.get(0);

      // Remove <op> element including its child element <Fun>, so
      // it will not be parsed twice
      expr.removeChild(op);
    }

    if (!foundOp) {
      fun = children.get(0);

      // Remove <Fun> element so that it will not be parsed twice
      expr.removeChild(fun);
    }

    if (!fun.getLocalName().equals(tagNames.FUN)) {
      throw new ParseException("First child of op in an Expr must be a Fun element.");
    }

    int symbol = SymbolTable.internSymbol(fun.getValue().trim());
    int typeid = parseTypeAttribute(expr);

    Vector<Term> subterms = parseDefaultElements(expr);
    Term t = new Term(symbol, SymbolTable.INOROLE, typeid, subterms);
    return t;
  }