Package nu.xom

Examples of nu.xom.IllegalAddException


    } else if (node instanceof ProcessingInstruction) {
      write((ProcessingInstruction) node);
    } else if (node instanceof DocType) {
      write((DocType) node);
    } else {
      throw new IllegalAddException("Cannot write node type: " + node);
    }
  }
View Full Code Here


      // append nodes:
      for (int j=0; j < nodes.size(); j++) {
        Node node = nodes.get(j);
        if (node instanceof Element) { // replace fake root with real root
          if (hasRootElement) {
            throw new IllegalAddException(
              "Factory returned multiple root elements");
          }
          doc.setRootElement((Element) node);
          hasRootElement = true;
        } else {
View Full Code Here

      } else if (node instanceof ProcessingInstruction) {
        writeProcessingInstruction((ProcessingInstruction) node);
      } else if (node instanceof DocType) {
        writeDocType((DocType) node);
      } else {
        throw new IllegalAddException("Cannot write node type: " + node);
      }
    }
    writeEndDocument();
    if (DEBUG) System.err.println("finished writing document");
  }
View Full Code Here

    } else if (node instanceof Comment) {
      writeComment((Comment) node);
    } else if (node instanceof ProcessingInstruction) {
      writeProcessingInstruction((ProcessingInstruction) node);
    } else {
      throw new IllegalAddException("Cannot write node type: " + node);
    }
  }
View Full Code Here

     
      Nodes nodes;
//      if (DEBUG) System.out.println(toString(reader.getEventType()));
      switch (reader.getEventType()) {
        case XMLStreamConstants.START_ELEMENT: {
          if (hasRootElement) throw new IllegalAddException(
            "StAX reader must not return multiple root elements");

          if (factory.getClass() == NodeFactory.class) { // fast path
            if (nodeBuilder == null) nodeBuilder = new NodeBuilder();
            Element root = readStartTag();
            addAttributes(root);
            addNamespaceDeclarations(root);
            readElement(root); // reads entire subtree
            nodes = new Nodes(root);
          } else { // slow path     
            Element root = readStartTagF(true);
            if (root == null) {
              throw new NullPointerException(
                "Factory failed to create root element.");
            }
            doc.setRootElement(root);
            addAttributesF(root);
            addNamespaceDeclarations(root);
            readElementF(root); // read entire subtree
            nodes = factory.finishMakingElement(root);
          }
          reader.require(XMLStreamConstants.END_ELEMENT, null, null);
          if (isFragmentMode) done = true;
          break;
        }
        case XMLStreamConstants.END_ELEMENT:
          throw new IllegalAddException(
            "A document must not have more than one root element");
        case XMLStreamConstants.PROCESSING_INSTRUCTION:
          nodes = factory.makeProcessingInstruction(
              reader.getPITarget(), reader.getPIData());
          break;
        case XMLStreamConstants.CHARACTERS:
          nodes = NONE; // ignore text in prolog/epilog
          break;
        case XMLStreamConstants.COMMENT:
          nodes = factory.makeComment(reader.getText());
          break;
        case XMLStreamConstants.SPACE:
          nodes = NONE; // ignore text in prolog/epilog
          break;
        case XMLStreamConstants.START_DOCUMENT:
          nodes = NONE; // has already been handled previously
          break;
        case XMLStreamConstants.END_DOCUMENT:
          throw new IllegalStateException("unreachable");
        case XMLStreamConstants.CDATA:
          nodes = NONE; // ignore text in prolog/epilog
          break;
        case XMLStreamConstants.ATTRIBUTE:
          throw new IllegalAddException(
            "Illegal attribute in prolog/epilog");
        case XMLStreamConstants.NAMESPACE:
          throw new IllegalAddException(
            "Illegal namespace declaration in prolog/epilog");
        case XMLStreamConstants.DTD:
          nodes = readDocType(factory); // FIXME
          break;
        case XMLStreamConstants.ENTITY_DECLARATION:
          nodes = NONE; // ignore (missing StAX support)
          break;
        case XMLStreamConstants.NOTATION_DECLARATION:
          nodes = NONE; // ignore (missing StAX support)
          break;
        case XMLStreamConstants.ENTITY_REFERENCE:
          nodes = NONE; // ignore text in prolog/epilog
          break;
        default:
          throw new XMLException("Unrecognized Stax event type: "
              + reader.getEventType());
      }
     
      // append nodes:
      for (int j=0; j < nodes.size(); j++) {
        Node node = nodes.get(j);
        if (node instanceof Element) { // replace fake root with real root
          if (hasRootElement) {
            throw new IllegalAddException(
              "Factory returned multiple root elements");
          }
          doc.setRootElement((Element) node);
          hasRootElement = true;
        } else {
View Full Code Here

    } else if (node instanceof ProcessingInstruction) {
      write((ProcessingInstruction) node);
    } else if (node instanceof DocType) {
      write((DocType) node);
    } else {
      throw new IllegalAddException("Cannot write node type: " + node);
    }
  }
View Full Code Here

      "writeXMLDeclaration() or 2) called writeEndDocument() " +
      "before without a subsequent writeXMLDeclaration()");
  }

  private static void throwWellformednessException(String message) {
    throw new IllegalAddException(message);
  }
View Full Code Here

      "writeXMLDeclaration() or 2) called writeEndDocument() " +
      "before without a subsequent writeXMLDeclaration()");
  }

  private static void throwWellformednessException(String message) {
    throw new IllegalAddException(message);
  }
View Full Code Here

    NodeInfo next;
    AxisIterator iter = node.iterateAxis(Axis.CHILD);
    while ((next = (NodeInfo) iter.next()) != null) {
      Node child = convertNodeInfo(next);
      if (child instanceof Element) { // replace fake root with real root
        if (hasRootElement) throw new IllegalAddException(
          "A XOM document must not have more than one root element.");
        doc.setRootElement((Element) child);
        hasRootElement = true;
      } else {
        doc.insertChild(child, i);
      }
      i++;
    }
    if (!hasRootElement) throw new IllegalAddException(
      "Missing document root element; A XOM document must have a root element.");
    return doc;
  }
View Full Code Here

        // append nodes:
        for (int j=0; j < nodes.size(); j++) {
          Node node = nodes.get(j);
          if (node instanceof Element) { // replace fake root with real root
            if (hasRootElement) {
              throw new IllegalAddException(
                "Factory returned multiple root elements");
            }
            result.setRootElement((Element) node);
            hasRootElement = true;
          } else {
View Full Code Here

TOP

Related Classes of nu.xom.IllegalAddException

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.