示例#1
0
  /**
   * This will output a list of JDOM nodes as a fragment of an XML document, firing off the SAX
   * events that have been registered.
   *
   * <p><strong>Warning</strong>: This method does not call the {@link
   * ContentHandler#setDocumentLocator}, {@link ContentHandler#startDocument} and {@link
   * ContentHandler#endDocument} callbacks on the {@link #setContentHandler ContentHandler}. The
   * user shall invoke these methods directly prior/after outputting the document fragments.
   *
   * @param nodes <code>List</code> of JDOM nodes to output.
   * @throws JDOMException if any error occurred.
   * @see #outputFragment(org.jdom2.Content)
   */
  public void outputFragment(List<? extends Content> nodes) throws JDOMException {
    if ((nodes == null) || (nodes.size() == 0)) {
      return;
    }

    // Output node list as a document fragment.
    elementContent(nodes, new NamespaceStack());
  }
示例#2
0
  /**
   * This will output a list of JDOM nodes as a document, firing off the SAX events that have been
   * registered.
   *
   * <p><strong>Warning</strong>: This method may output ill-formed XML documents if the list
   * contains top-level objects that are not legal at the document level (e.g. Text or CDATA nodes,
   * multiple Element nodes, etc.). Thus, it should only be used to output document portions towards
   * ContentHandlers capable of accepting such ill-formed documents (such as XSLT processors).
   *
   * @param nodes <code>List</code> of JDOM nodes to output.
   * @throws JDOMException if any error occurred.
   * @see #output(org.jdom2.Document)
   */
  public void output(List<? extends Content> nodes) throws JDOMException {
    if ((nodes == null) || (nodes.size() == 0)) {
      return;
    }

    // contentHandler.setDocumentLocator()
    documentLocator(null);

    // contentHandler.startDocument()
    startDocument();

    // Process node list.
    elementContent(nodes, new NamespaceStack());

    // contentHandler.endDocument()
    endDocument();
  }