Exemple #1
0
 /* 514:    */
 /* 515:    */ protected void endPrefixMapping(NamespaceStack stack, int stackSize)
     /* 516:    */ throws SAXException
       /* 517:    */ {
   /* 518:799 */ while (stack.size() > stackSize)
   /* 519:    */ {
     /* 520:800 */ Namespace namespace = stack.pop();
     /* 521:802 */ if (namespace != null) {
       /* 522:803 */ this.contentHandler.endPrefixMapping(namespace.getPrefix());
       /* 523:    */ }
     /* 524:    */ }
   /* 525:    */ }
Exemple #2
0
  // Implementation methods
  // -------------------------------------------------------------------------
  protected void writeElement(Element element) throws IOException {
    int size = element.nodeCount();
    String qualifiedName = element.getQualifiedName();

    writePrintln();
    indent();

    writer.write("<");
    writer.write(qualifiedName);

    int previouslyDeclaredNamespaces = namespaceStack.size();
    Namespace ns = element.getNamespace();

    if (isNamespaceDeclaration(ns)) {
      namespaceStack.push(ns);
      writeNamespace(ns);
    }

    // Print out additional namespace declarations
    boolean textOnly = true;

    for (int i = 0; i < size; i++) {
      Node node = element.node(i);

      if (node instanceof Namespace) {
        Namespace additional = (Namespace) node;

        if (isNamespaceDeclaration(additional)) {
          namespaceStack.push(additional);
          writeNamespace(additional);
        }
      } else if (node instanceof Element) {
        textOnly = false;
      } else if (node instanceof Comment) {
        textOnly = false;
      }
    }

    writeAttributes(element);

    lastOutputNodeType = Node.ELEMENT_NODE;

    if (size <= 0) {
      writeEmptyElementClose(qualifiedName);
    } else {
      writer.write(">");

      if (textOnly) {
        // we have at least one text node so lets assume
        // that its non-empty
        writeElementContent(element);
      } else {
        // we know it's not null or empty from above
        ++indentLevel;

        writeElementContent(element);

        --indentLevel;

        writePrintln();
        indent();
      }

      writer.write("</");
      writer.write(qualifiedName);
      writer.write(">");
    }

    // remove declared namespaceStack from stack
    while (namespaceStack.size() > previouslyDeclaredNamespaces) {
      namespaceStack.pop();
    }

    lastOutputNodeType = Node.ELEMENT_NODE;
  }