Exemple #1
0
    /**
     * Returns the content of a JDOM Element detached from it.
     *
     * @param elt the element to get the content from.
     * @return a (possibly empty) list of JDOM nodes, detached from their parent.
     */
    private List getDetachedContent(Element elt) {
      List content = elt.getContent();
      List nodes = new ArrayList(content.size());

      while (content.size() != 0) {
        Object o = content.remove(0);
        nodes.add(o);
      }
      return (nodes);
    }
Exemple #2
0
  /**
   * Returns the result of an XSL Transformation as a list of JDOM nodes.
   *
   * <p>If the result of the transformation is a JDOM document, this method converts it into a list
   * of JDOM nodes; any subsequent call to {@link #getDocument} will return <code>null</code>.
   *
   * @return the transformation result as a (possibly empty) list of JDOM nodes (Elements, Texts,
   *     Comments, PIs...).
   */
  public List getResult() {
    List nodes = Collections.EMPTY_LIST;

    // Retrieve result from the document builder if not set.
    this.retrieveResult();

    if (result instanceof List) {
      nodes = (List) result;
    } else {
      if ((result instanceof Document) && (queried == false)) {
        List content = ((Document) result).getContent();
        nodes = new ArrayList(content.size());

        while (content.size() != 0) {
          Object o = content.remove(0);
          nodes.add(o);
        }
        result = nodes;
      }
    }
    queried = true;

    return (nodes);
  }