コード例 #1
0
  /**
   * This will recursively invoke all of the callbacks for a particular element.
   *
   * @param element <code>Element</code> used in callbacks.
   * @param namespaces <code>List</code> stack of Namespaces in scope.
   */
  private void element(Element element, NamespaceStack stack) throws JDOMException {

    AttributesImpl nsAtts = null; // The namespaces as xmlns attributes

    // contentHandler.startPrefixMapping()
    stack.push(element);
    try {
      for (Namespace ns : stack.addedForward()) {
        startPrefixMapping(ns);
        nsAtts = this.addNsAttribute(nsAtts, ns);
      }

      // contentHandler.startElement()
      startElement(element, nsAtts);

      // handle content in the element
      elementContent(element.getContent(), stack);

      // update locator
      if (locator != null) {
        locator.setNode(element);
      }

      // contentHandler.endElement()
      endElement(element);
    } finally {
      stack.pop();
    }

    // contentHandler.endPrefixMapping()
    // de-map in reverse order to the mapping.
    for (Namespace ns : stack.addedReverse()) {
      endPrefixMapping(ns);
    }
  }
コード例 #2
0
ファイル: JDOMResult.java プロジェクト: vlady21/jclic
    /**
     * 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);
    }
コード例 #3
0
ファイル: SAXOutputter.java プロジェクト: vlady21/jclic
  /**
   * This will recursively invoke all of the callbacks for a particular element.
   *
   * @param element <code>Element</code> used in callbacks.
   * @param namespaces <code>List</code> stack of Namespaces in scope.
   */
  private void element(Element element, NamespaceStack namespaces) throws JDOMException {
    // used to check endPrefixMapping
    int previouslyDeclaredNamespaces = namespaces.size();

    // contentHandler.startPrefixMapping()
    Attributes nsAtts = startPrefixMapping(element, namespaces);

    // contentHandler.startElement()
    startElement(element, nsAtts);

    // handle content in the element
    elementContent(element.getContent(), namespaces);

    // update locator
    locator.setNode(element);

    // contentHandler.endElement()
    endElement(element);

    // contentHandler.endPrefixMapping()
    endPrefixMapping(namespaces, previouslyDeclaredNamespaces);
  }