protected Document generateAntTask() {
    try {
      DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
      Document doc = factory.newDocumentBuilder().newDocument();
      Element root = doc.createElement("project"); // $NON-NLS-1$
      root.setAttribute("name", "build"); // $NON-NLS-1$ //$NON-NLS-2$
      root.setAttribute("default", "feature_export"); // $NON-NLS-1$ //$NON-NLS-2$
      doc.appendChild(root);

      Element target = doc.createElement("target"); // $NON-NLS-1$
      target.setAttribute("name", "feature_export"); // $NON-NLS-1$ //$NON-NLS-2$
      root.appendChild(target);

      Element export = doc.createElement("pde.exportFeatures"); // $NON-NLS-1$
      export.setAttribute("features", getFeatureIDs()); // $NON-NLS-1$
      export.setAttribute("destination", fPage.getDestination()); // $NON-NLS-1$
      String filename = fPage.getFileName();
      if (filename != null) export.setAttribute("filename", filename); // $NON-NLS-1$
      export.setAttribute("exportType", getExportOperation()); // $NON-NLS-1$
      export.setAttribute("useJARFormat", Boolean.toString(fPage.useJARFormat())); // $NON-NLS-1$
      export.setAttribute("exportSource", Boolean.toString(fPage.doExportSource())); // $NON-NLS-1$
      if (fPage.doExportSource()) {
        export.setAttribute(
            "exportSourceBundle", Boolean.toString(fPage.doExportSourceBundles())); // $NON-NLS-1$
      }
      String qualifier = fPage.getQualifier();
      if (qualifier != null) export.setAttribute("qualifier", qualifier); // $NON-NLS-1$
      target.appendChild(export);
      return doc;
    } catch (DOMException e) {
    } catch (FactoryConfigurationError e) {
    } catch (ParserConfigurationException e) {
    }
    return null;
  }
  private Element generatePortNode(Document doc, Port port) {
    Element portEl = doc.createElement(EL_PORT);

    portEl.setAttribute(ATR_NAME, port.getName());
    portEl.setAttribute(ATR_TYPE, port.getType());
    portEl.setAttribute(ATR_X, Integer.toString(port.getX()));
    portEl.setAttribute(ATR_Y, Integer.toString(port.getY()));
    portEl.setAttribute(ATR_PORT_CONNECTION, port.isArea() ? "area" : "");
    portEl.setAttribute(ATR_STRICT, Boolean.toString(port.isStrict()));
    portEl.setAttribute(ATR_MULTI, Boolean.toString(port.isMulti()));

    return portEl;
  }
  private Element generateGraphicsNode(Document doc, ClassGraphics gr) {

    Element graphicsEl = doc.createElement(EL_GRAPHICS);

    Element bounds = doc.createElement(EL_BOUNDS);
    graphicsEl.appendChild(bounds);
    bounds.setAttribute(ATR_X, Integer.toString(gr.getBoundX()));
    bounds.setAttribute(ATR_Y, Integer.toString(gr.getBoundY()));
    bounds.setAttribute(ATR_WIDTH, Integer.toString(gr.getBoundWidth()));
    bounds.setAttribute(ATR_HEIGHT, Integer.toString(gr.getBoundHeight()));

    for (Shape shape : gr.getShapes()) {

      if (shape instanceof Rect) {
        Rect rect = (Rect) shape;
        Element rectEl = doc.createElement(EL_RECT);
        graphicsEl.appendChild(rectEl);
        rectEl.setAttribute(ATR_X, Integer.toString(rect.getX()));
        rectEl.setAttribute(ATR_Y, Integer.toString(rect.getY()));
        rectEl.setAttribute(ATR_WIDTH, Integer.toString(rect.getWidth()));
        rectEl.setAttribute(ATR_HEIGHT, Integer.toString(rect.getHeight()));
        rectEl.setAttribute(ATR_COLOUR, Integer.toString(rect.getColor().getRGB()));
        rectEl.setAttribute(ATR_FILLED, Boolean.toString(rect.isFilled()));
        rectEl.setAttribute(ATR_FIXED, Boolean.toString(rect.isFixed()));
        rectEl.setAttribute(ATR_STROKE, Float.toString(rect.getStroke().getLineWidth()));
        rectEl.setAttribute(ATR_LINETYPE, Float.toString(rect.getLineType()));
        rectEl.setAttribute(ATR_TRANSPARENCY, Integer.toString(rect.getTransparency()));
      } else if (shape instanceof Text) {
        Text text = (Text) shape;
        Element textEl = doc.createElement(EL_TEXT);
        textEl.setAttribute(ATR_STRING, text.getText());
        textEl.setAttribute(ATR_X, Integer.toString(text.getX()));
        textEl.setAttribute(ATR_Y, Integer.toString(text.getY()));
        textEl.setAttribute(ATR_FONTNAME, text.getFont().getName());
        textEl.setAttribute(ATR_FONTSIZE, Integer.toString(text.getFont().getSize()));
        textEl.setAttribute(ATR_FONTSTYLE, Integer.toString(text.getFont().getStyle()));
        textEl.setAttribute(ATR_TRANSPARENCY, Integer.toString(text.getTransparency()));
        textEl.setAttribute(ATR_COLOUR, Integer.toString(text.getColor().getRGB()));
        graphicsEl.appendChild(textEl);
      } // TODO handle the rest of shapes
    }

    return graphicsEl;
  }