Exemple #1
0
  /**
   * This will invoke the callbacks for the content of an element.
   *
   * @param node a <code>Content</code> node.
   * @param namespaces <code>List</code> stack of Namespaces in scope.
   */
  private void elementContent(Content node, NamespaceStack namespaces) throws JDOMException {
    // update locator
    locator.setNode(node);

    if (node instanceof Element) {
      element((Element) node, namespaces);
    } else if (node instanceof CDATA) {
      cdata(((CDATA) node).getText());
    } else if (node instanceof Text) {
      // contentHandler.characters()
      characters(((Text) node).getText());
    } else if (node instanceof ProcessingInstruction) {
      // contentHandler.processingInstruction()
      processingInstruction((ProcessingInstruction) node);
    } else if (node instanceof Comment) {
      // lexicalHandler.comment()
      comment(((Comment) node).getText());
    } else if (node instanceof EntityRef) {
      // contentHandler.skippedEntity()
      entityRef((EntityRef) node);
    } else {
      // Not a valid element child. This could happen with
      // application-provided lists which may contain non
      // JDOM objects.
      handleError(new JDOMException("Invalid element content: " + node));
    }
  }
Exemple #2
0
  /**
   * This will invoke the callbacks for the content of an element.
   *
   * @param content element content as a <code>List</code> of nodes.
   * @param namespaces <code>List</code> stack of Namespaces in scope.
   */
  private void elementContent(List content, NamespaceStack namespaces) throws JDOMException {
    for (Iterator i = content.iterator(); i.hasNext(); ) {
      Object obj = i.next();

      if (obj instanceof Content) {
        this.elementContent((Content) obj, namespaces);
      } else {
        // Not a valid element child. This could happen with
        // application-provided lists which may contain non
        // JDOM objects.
        handleError(new JDOMException("Invalid element content: " + obj));
      }
    }
  }