Пример #1
0
  /**
   * Recursively evaluates an element.
   *
   * @param element the element
   * @return the result of processing the element
   * @throws ProcessorException if there is an error in processing
   */
  @SuppressWarnings("unchecked")
  public String evaluate(Element element) throws ProcessorException {
    // Is it a valid element?
    if (element == null) {
      return "";
    }

    // Search for the tag in the processor registry.
    Class<? extends P> processorClass = null;

    String elementNamespaceURI = element.getNamespaceURI();
    Document elementDocument = element.getDocument();
    boolean emitXMLNS =
        elementDocument != null
            && (element.equals(element.getDocument().getRootElement())
                || (elementNamespaceURI != null
                    && !elementNamespaceURI.equals(
                        element.getDocument().getRootElement().getNamespaceURI())));
    if (elementNamespaceURI == null
        || this._registry.getNamespaceURI().equals(elementNamespaceURI)) {
      processorClass = this._registry.get(element.getName());

      // Process the element with a new instance of the processor.
      return Classes.getNewInstance(processorClass, "Processor", this._core).process(element, this);
    }
    // otherwise (if this element is from a different namespace)
    if (element.getContent().size() == 0) {
      return JDOM.renderEmptyElement(element, emitXMLNS);
    }
    // otherwise...
    return JDOM.renderStartTag(element, emitXMLNS)
        + evaluate(element.getContent())
        + JDOM.renderEndTag(element);
  }
Пример #2
0
 public void fillFiles(Table table) {
   table.removeAll();
   int index = 0;
   if (_resources != null) {
     for (Iterator it = _resources.getChildren("file", _dom.getNamespace()).iterator();
         it.hasNext(); ) {
       Element file = (Element) it.next();
       TableItem item = new TableItem(table, SWT.NONE);
       item.setText(0, Utils.getAttributeValue("file", file));
       item.setText(1, Utils.getAttributeValue("os", file));
       item.setText(2, Utils.getAttributeValue("type", file));
       item.setText(3, Utils.getAttributeValue("id", file));
       if (file.equals(_file)) table.select(index);
       index++;
     }
   }
 }