Esempio n. 1
0
  NodeList getElementsByTagName(final Parent xshadow, final String tagname) {
    if (tagname == null) {
      return EMPTYLIST;
    }
    final ArrayList<JElement> enodes = new ArrayList<JElement>();
    if (xshadow != null) {
      final Iterator<org.jdom2.Element> it = xshadow.getDescendants(Filters.element());

      org.jdom2.Element e = null;
      if (xshadow instanceof org.jdom2.Element) {
        e = (org.jdom2.Element) xshadow;
      } else {
        if (it.hasNext()) {
          e = it.next();
        }
      }
      while (e != null) {
        if ("*".equals(tagname) || tagname.equals(e.getQualifiedName())) {
          enodes.add(find(e));
        }
        e = it.hasNext() ? it.next() : null;
      }
    }
    return new JNodeList(enodes);
  }
Esempio n. 2
0
  /**
   * This will invoke the <code>endElement</code> callback in the <code>ContentHandler</code>.
   *
   * @param element <code>Element</code> used in callbacks.
   */
  private void endElement(Element element) throws JDOMException {
    String namespaceURI = element.getNamespaceURI();
    String localName = element.getName();
    String rawName = element.getQualifiedName();

    try {
      contentHandler.endElement(namespaceURI, localName, rawName);
    } catch (SAXException se) {
      throw new JDOMException("Exception in endElement", se);
    }
  }
Esempio n. 3
0
  /**
   * This will invoke the <code>startElement</code> callback in the <code>ContentHandler</code>.
   *
   * @param element <code>Element</code> used in callbacks.
   * @param nsAtts <code>List</code> of namespaces to declare with the element or <code>null</code>.
   */
  private void startElement(Element element, Attributes nsAtts) throws JDOMException {
    String namespaceURI = element.getNamespaceURI();
    String localName = element.getName();
    String rawName = element.getQualifiedName();

    // Allocate attribute list.
    AttributesImpl atts = (nsAtts != null) ? new AttributesImpl(nsAtts) : new AttributesImpl();

    for (Attribute a : element.getAttributes()) {
      atts.addAttribute(
          a.getNamespaceURI(),
          a.getName(),
          a.getQualifiedName(),
          getAttributeTypeName(a.getAttributeType()),
          a.getValue());
    }

    try {
      contentHandler.startElement(namespaceURI, localName, rawName, atts);
    } catch (SAXException se) {
      throw new JDOMException("Exception in startElement", se);
    }
  }