Exemple #1
0
 /**
  * This will invoke the <code>endPrefixMapping</code> callback in the <code>ContentHandler</code>
  * when a namespace is goes out of scope in the <code>Document</code>.
  *
  * @param namespaces <code>List</code> stack of Namespaces in scope.
  * @param previouslyDeclaredNamespaces number of previously declared namespaces
  */
 private void endPrefixMapping(NamespaceStack namespaces, int previouslyDeclaredNamespaces)
     throws JDOMException {
   while (namespaces.size() > previouslyDeclaredNamespaces) {
     String prefix = namespaces.pop();
     try {
       contentHandler.endPrefixMapping(prefix);
     } catch (SAXException se) {
       throw new JDOMException("Exception in endPrefixMapping", se);
     }
   }
 }
Exemple #2
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 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);
  }