protected void handleParent(Element e, NameSpaceSymbTable ns) {
    if (!e.hasAttributes() && e.getNamespaceURI() == null) {
      return;
    }
    xmlattrStack.push(-1);
    NamedNodeMap attrs = e.getAttributes();
    int attrsLength = attrs.getLength();
    for (int i = 0; i < attrsLength; i++) {
      Attr attribute = (Attr) attrs.item(i);
      String NName = attribute.getLocalName();
      String NValue = attribute.getNodeValue();

      if (Constants.NamespaceSpecNS.equals(attribute.getNamespaceURI())) {
        if (!XML.equals(NName) || !Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
          ns.addMapping(NName, NValue, attribute);
        }
      } else if (!"id".equals(NName) && XML_LANG_URI.equals(attribute.getNamespaceURI())) {
        xmlattrStack.addXmlnsAttr(attribute);
      }
    }
    if (e.getNamespaceURI() != null) {
      String NName = e.getPrefix();
      String NValue = e.getNamespaceURI();
      String Name;
      if (NName == null || NName.equals("")) {
        NName = "xmlns";
        Name = "xmlns";
      } else {
        Name = "xmlns:" + NName;
      }
      Attr n = e.getOwnerDocument().createAttributeNS("http://www.w3.org/2000/xmlns/", Name);
      n.setValue(NValue);
      ns.addMapping(NName, NValue, n);
    }
  }
  /**
   * Adds to ns the definitons from the parent elements of el
   *
   * @param el
   * @param ns
   */
  static final void getParentNameSpaces(Element el, NameSpaceSymbTable ns) {
    List parents = new ArrayList();
    Node n1 = el.getParentNode();
    if (!(n1 instanceof Element)) {
      return;
    }
    // Obtain all the parents of the elemnt
    Element parent = (Element) el.getParentNode();
    while (parent != null) {
      parents.add(parent);
      Node n = parent.getParentNode();
      if (!(n instanceof Element)) {
        break;
      }
      parent = (Element) n;
    }
    // Visit them in reverse order.
    ListIterator it = parents.listIterator(parents.size());
    while (it.hasPrevious()) {
      Element ele = (Element) it.previous();
      if (!ele.hasAttributes()) {
        continue;
      }
      NamedNodeMap attrs = ele.getAttributes();
      int attrsLength = attrs.getLength();
      for (int i = 0; i < attrsLength; i++) {
        Attr N = (Attr) attrs.item(i);
        if (!Constants.NamespaceSpecNS.equals(N.getNamespaceURI())) {
          // Not a namespace definition, ignore.
          continue;
        }

        String NName = N.getLocalName();
        String NValue = N.getNodeValue();
        if (XML.equals(NName) && Constants.XML_LANG_SPACE_SpecNS.equals(NValue)) {
          continue;
        }
        ns.addMapping(NName, NValue, N);
      }
    }
    Attr nsprefix;
    if (((nsprefix = ns.getMappingWithoutRendered("xmlns")) != null)
        && "".equals(nsprefix.getValue())) {
      ns.addMappingAndRender("xmlns", "", nullNode);
    }
  }