示例#1
0
  /** Reads the XML data and create the data */
  public void readDOMDataElement(Element element, IDataSets datasets) {
    // start with source data
    for (Object child : CodeFragment.getDataElementsOfType(CodeFragment.TYPE.SOURCE, element)) {
      Element code = (Element) child;
      try {
        collectSourceDataFromDOM(code, datasets);
      } catch (Exception e) {
        e.printStackTrace();
        Util.errorMessage(
            "Failed to load source "
                + code.getAttributeValue("name")
                + ", error "
                + e.getMessage());
      }
    }

    // process the data
    for (Object child : CodeFragment.getDataElementsOfType(CodeFragment.TYPE.GENERATED, element)) {
      Element code = (Element) child;
      try {
        processDataFromDOM(code, datasets);
      } catch (Exception e) {
        e.printStackTrace();
        Util.errorMessage("Failed to run process " + e.getMessage());
      }
    }
  }
  /*
    Iterates through the element tree and prints
    out each element and its attributes.
  */
  private void dumpTree() {

    Element elem;
    while (true) {
      if ((elem = next()) != null) {
        System.out.println("elem: " + elem.getName());
        AttributeSet attr = elem.getAttributes();
        String s = "";
        Enumeration names = attr.getAttributeNames();
        while (names.hasMoreElements()) {
          Object key = names.nextElement();
          Object value = attr.getAttribute(key);
          if (value instanceof AttributeSet) {
            // don't go recursive
            s = s + key + "=**AttributeSet** ";
          } else {
            s = s + key + "=" + value + " ";
          }
        }
        System.out.println("attributes: " + s);
      } else {
        break;
      }
    }
  }
示例#3
0
  /**
   * Search the tree of objects starting at the given <code>ServerActiveHtml</code> and return the
   * content of the first <code>Element</code> with the same name as this <code>Placeholder</code>
   * as the children of a new <code>List</code> if the <code>Element</code> does not have a any
   * placeholder (of the form placeholder-x = "foo").
   *
   * <p>Otherise return a singleton list of a <code>ServerActiveHtml</code> which has the children
   * of the found <code>Element</code> and the placeholders of this <code>Element</code>
   *
   * <p>Packaging the content of the matched <code>Element</code> as a <code>ServerActiveHtml</code>
   * allows the placeholders of the <code>Element</code> to be transferred to the <code>
   * ServerActiveHtml</code>
   *
   * <p>If no matching <code>Element</code> return a <code>List</code> with a <code>Fragment</code>
   * warning message
   *
   * @return A <code>ServerActiveHtml</code> containing the child of the matched <code>Element
   *     </code> or a warning <code>Fragment</code> if no matching <code>Element</code>
   */
  public List getReplacement(ServerActiveHtml sah) throws ServerActiveHtmlException {

    List result = new LinkedList();

    Element match = sah.findElement(getUseElement());

    if (match == null) {
      result.add(
          new Fragment(
              "<b>Warning: missing element for placeholder '" + getUseElement() + "'</b>"));
      return result;
    }

    if (match.getPlaceholders().isEmpty()) {
      for (Iterator children = match.getChildren().iterator(); children.hasNext(); ) {
        Deserializable child = (Deserializable) children.next();
        result.add(child);
      }
    } else {
      ServerActiveHtml wrapper = new ServerActiveHtml(REPLACEMENT_NAME);
      wrapper.setPlaceholders(match.getPlaceholders());
      for (Iterator children = match.getChildren().iterator(); children.hasNext(); ) {
        Deserializable child = (Deserializable) children.next();
        wrapper.add(child);
      }
      result.add(wrapper);
    }

    return result;
  }
示例#4
0
  /** {@inheritDoc} */
  public void initializeFrom(Element element) throws DocumentSerializationException {
    for (Enumeration e = element.getChildren(); e.hasMoreElements(); ) {
      Element serviceElement = (TextElement) e.nextElement();
      String tagName = (String) serviceElement.getKey();

      if (tagName.equals("service")) {
        try {
          ModuleClassID moduleClassID =
              (ModuleClassID)
                  IDFactory.fromURI(
                      new URI(
                          DocumentSerializableUtilities.getString(
                              serviceElement, "moduleClassID", "ERROR")));

          try {
            ServiceMonitorFilter serviceMonitorFilter =
                MonitorResources.createServiceMonitorFilter(moduleClassID);
            serviceMonitorFilter.init(moduleClassID);
            Element serviceMonitorFilterElement =
                DocumentSerializableUtilities.getChildElement(serviceElement, "serviceFilter");
            serviceMonitorFilter.initializeFrom(serviceMonitorFilterElement);
            serviceMonitorFilters.put(moduleClassID, serviceMonitorFilter);
          } catch (Exception ex) {
            if (unknownModuleClassIDs == null) unknownModuleClassIDs = new LinkedList();

            unknownModuleClassIDs.add(moduleClassID);
          }
        } catch (URISyntaxException jex) {
          throw new DocumentSerializationException("Can't get ModuleClassID", jex);
        }
      }
    }
  }
 /**
  * Create a new AbstractWriter with the indicated Writer and Element. The full range of the
  * Element will be used.
  */
 protected AbstractWriter(Writer writer, Element elt) {
   this.writer = writer;
   this.iter = new ElementIterator(elt);
   this.document = elt.getDocument();
   this.startOffset = elt.getStartOffset();
   this.endOffset = elt.getEndOffset();
 }
示例#6
0
	/*
	 * 递归完成查找
	 * para: Element root 开始查找节点
	 */
	public Element findNode(Element root,String sNodeName)
	{
		Element node =null;
		try
		{
			String sName="";
			List list=root.getChildren();
			for(int i=0;i<list.size();i++)
			{
				node=(Element)list.get(i);
				sName=node.getName();
				sName=sName.trim();
				//System.err.println("node name:"+sName+"-"+sNodeName);
				if(sName.equals(sNodeName))
				{
					System.err.println("find the node:"+sName);
					return node;
				}
				node=findNode(node,sNodeName);
			}
		}catch(Exception ex)
		{
			ex.printStackTrace();
			System.err.println("error:"+ex.getMessage());
		}
		return node;
	}
  public void addGroup(LanguageGroup group, LanguageGroup parent, Language language) {
    Element parentElement = getParentElement(parent, language);

    Element newGroup = this.factory.createGroupElement(group);
    parentElement.appendChild(newGroup);
    writeDocument();
  }
  public static void main(String[] args) throws Exception {

    // final Logger log = Logger.getLogger(sample.class.getCanonicalName());
    JobData jd = new JobData();

    Scanner input = new Scanner(System.in);
    try {
      System.out.print("What is your user name? ");
      jd.setUsername(input.next());
      System.out.print("What is your password? ");
      jd.setPassword(input.next());
    } catch (Exception e) {
      // log.log(Level. SEVERE, "The system encountered an exception while attempting to login");
    } finally {
      input.close();
    }

    jd.setJob("TestREST");
    jd.setServer("http://10.94.0.137");
    jd.setPort("8006");

    URL url = new URL("http://10.94.0.137:8006/api/xml");
    Document dom = new SAXReader().read(url);

    for (Element job : (List<Element>) dom.getRootElement().elements("job")) {
      System.out.println(
          String.format(
              "Job %s with URL %s has status %s",
              job.elementText("name"), job.elementText("url"), job.elementText("color")));
    }
  }
示例#9
0
 // Serialize the bean using the specified namespace prefix & uri
 public String serialize(Object bean) throws IntrospectionException, IllegalAccessException {
   // Use the class name as the name of the root element
   String className = bean.getClass().getName();
   String rootElementName = null;
   if (bean.getClass().isAnnotationPresent(ObjectXmlAlias.class)) {
     AnnotatedElement annotatedElement = bean.getClass();
     ObjectXmlAlias aliasAnnotation = annotatedElement.getAnnotation(ObjectXmlAlias.class);
     rootElementName = aliasAnnotation.value();
   }
   // Use the package name as the namespace URI
   Package pkg = bean.getClass().getPackage();
   nsURI = pkg.getName();
   // Remove a trailing semi-colon (;) if present (i.e. if the bean is an array)
   className = StringUtils.deleteTrailingChar(className, ';');
   StringBuffer sb = new StringBuffer(className);
   String objectName = sb.delete(0, sb.lastIndexOf(".") + 1).toString();
   domDocument = createDomDocument(objectName);
   document = domDocument.getDocument();
   Element root = document.getDocumentElement();
   // Parse the bean elements
   getBeanElements(root, rootElementName, className, bean);
   StringBuffer xml = new StringBuffer();
   if (prettyPrint)
     xml.append(domDocument.serialize(lineSeperator, indentChars, includeXmlProlog));
   else xml.append(domDocument.serialize(includeXmlProlog));
   if (!includeTypeInfo) {
     int index = xml.indexOf(root.getNodeName());
     xml.delete(index - 1, index + root.getNodeName().length() + 2);
     xml.delete(xml.length() - root.getNodeName().length() - 4, xml.length());
   }
   return xml.toString();
 }
示例#10
0
 private void analyseDocument(Document document, int lineNum, PythonIndentation indentationLogic)
     throws BadLocationException {
   Element map = document.getDefaultRootElement();
   int endPos = map.getElement(lineNum).getEndOffset();
   indentationLogic.reset();
   indentationLogic.addText(document.getText(0, endPos));
 }
示例#11
0
    private static int getNSVisualPosition(EditorPane txt, int pos, int direction) {
      Element root = txt.getDocument().getDefaultRootElement();
      int numLines = root.getElementIndex(txt.getDocument().getLength() - 1) + 1;
      int line = root.getElementIndex(pos) + 1;
      int tarLine = direction == SwingConstants.NORTH ? line - 1 : line + 1;
      try {
        if (tarLine <= 0) {
          return 0;
        }
        if (tarLine > numLines) {
          return txt.getDocument().getLength();
        }

        Rectangle curRect = txt.modelToView(pos);
        Rectangle tarEndRect;
        if (tarLine < numLines) {
          tarEndRect = txt.modelToView(txt.getLineStartOffset(tarLine) - 1);
        } else {
          tarEndRect = txt.modelToView(txt.getDocument().getLength() - 1);
        }
        Debug.log(9, "curRect: " + curRect + ", tarEnd: " + tarEndRect);

        if (curRect.x > tarEndRect.x) {
          pos = txt.viewToModel(new Point(tarEndRect.x, tarEndRect.y));
        } else {
          pos = txt.viewToModel(new Point(curRect.x, tarEndRect.y));
        }
      } catch (BadLocationException e) {
        Debug.error(me + "Problem getting next visual position\n%s", e.getMessage());
      }

      return pos;
    }
示例#12
0
    private void regenerate()
        throws ParseException
    {
        Enumeration enumeration;
        dict_ = Sparta.newCache();
        enumeration = visitor(xpath_, false).getResultEnumeration();
_L1:
        if (!enumeration.hasMoreElements())
        {
            return;
        }
        Vector vector;
        Vector vector1;
        Element element;
        String s;
        try
        {
            element = (Element)enumeration.nextElement();
            s = element.getAttribute(attrName_);
            vector1 = (Vector)dict_.t(s);
        }
        catch (XPathException xpathexception)
        {
            throw new ParseException("XPath problem", xpathexception);
        }
        vector = vector1;
        if (vector1 != null)
        {
            break MISSING_BLOCK_LABEL_98;
        }
        vector = new Vector(1);
        dict_.t(s, vector);
        vector.addElement(element);
          goto _L1
示例#13
0
  public static List<String> getEventsNameByXml() {
    SAXBuilder sxb = new SAXBuilder();
    Document document;
    List<String> listEvenementsString = null;
    //		Object obj=null;
    try {
      document = sxb.build(new File(xmlDefaultPath));

      //			listevents=getEventsNameByDoc(document);

      Element racine = document.getRootElement();

      //			System.out.println("racine="+racine.getText()+"finracine");
      List<Element> listEvenementsElement = racine.getChildren("evenement");
      listEvenementsString = new ArrayList<String>();

      for (Element evenementElement : listEvenementsElement) {
        listEvenementsString.add(evenementElement.getAttributeValue("nomEvent"));
      }

      //			System.out.println("listofEventsJdomtaille ="+listEvenementsString.size());

      // il faut valider le fichier xml avec la dtd
      //			JDomOperations.validateJDOM(document);
      //			afficheXml(document);
    } catch (Exception e) {
      // afficher un popup qui dit que le format du fichier xml entré n'est pas valide
      System.out.println("format xml non respecté");
      System.out.println(e.getMessage());
    }
    return listEvenementsString;
  }
示例#14
0
 public void save(boolean forcenew) {
   String filename = "";
   if ((m_filename.length() == 0) || forcenew) {
     FileDialog dialog = new FileDialog(new Shell(), SWT.SAVE);
     if (dialog.open() == null) {
       return;
     }
     filename = dialog.getFilterPath() + "/" + dialog.getFileName();
   } else {
     filename = m_filename;
   }
   FileOutputStream fileoutputstream;
   try {
     fileoutputstream = new FileOutputStream(filename);
     writeToStream(fileoutputstream);
     m_filename = filename;
     Element element = new Element("com.metaaps.eoclipse.workflow.filename");
     element.setAttribute("filename", m_filename);
     Util.setConfiguration(element, "filename");
   } catch (FileNotFoundException e) {
     e.printStackTrace();
     Util.errorMessage("Could not access file");
   } catch (IOException e) {
     e.printStackTrace();
     Util.errorMessage("Could not save file");
   }
 }
示例#15
0
  public String SqlExcute(String xmlStr) {
    String outstr = "false";
    Document doc;
    Element rootNode;
    String intStr = Basic.decode(xmlStr);

    try {
      Reader reader = new StringReader(intStr);
      SAXBuilder ss = new SAXBuilder();
      doc = ss.build(reader);

      rootNode = doc.getRootElement();

      List list = rootNode.getChildren();

      DBTable datatable = new DBTable();

      for (int i = 0; i < list.size(); i++) {
        Element childRoot = (Element) list.get(i);
        // System.out.print(childRoot.getText());
        outstr = String.valueOf(datatable.SaveDateStr(childRoot.getText()));
      }

    } catch (JDOMException ex) {
      System.out.print(ex.getMessage());
    }
    return outstr;
  }
示例#16
0
 private void writeProperties(Writer writer, Element e) throws IOException {
   for (String key : e.getPropertyKeys()) {
     Object property = e.getProperty(key);
     writeKey(writer, key);
     writeProperty(writer, property, 0);
   }
 }
示例#17
0
 /** Establece el sub-elemento Source */
 private void setSource() {
   Element eAux;
   eAux = new Element("Source");
   // eAux.setAttribute("Type","pcap o xml");
   eAux.setText(getPBExport().getExpSource());
   addContent(eAux);
 }
示例#18
0
 /**
  * trigger method is used to update foreign keys in the dataObjects this method is used before
  * saving objects in database thank's to the "saved fragment"
  *
  * @param old_id represents the past id of our GpsGeom
  * @param new_id represents the new id of our GpsGeom
  * @param photo represents the photo which we are working on and therefore is related to this
  *     gpsGeom
  * @param list_projet represents the projects that are related to this gpsGeom
  * @param list_element represents the projects that are related to this gpsGeom
  */
 public void trigger(
     long old_id,
     long new_id,
     Photo photo,
     ArrayList<Project> list_projet,
     ArrayList<Element> list_element) {
   /** we update gpsGeom_id from past to new in the photo that is geolocalised by this gpsGeom */
   if (photo.getGpsGeom_id() == old_id) {
     photo.setGpsGeom_id(new_id);
   }
   /**
    * we update gpsGeom_id from past to new in the projects that are geolocalised by this gpsGeom
    */
   if (list_projet != null) {
     for (Project p : list_projet) {
       if (p.getGpsGeom_id() == old_id) {
         p.setGpsGeom_id(new_id);
       }
     }
   }
   /**
    * we update gpsGeom_id from past to new in the elements that are geolocalised by this gpsGeom
    */
   if (list_element != null) {
     for (Element e : list_element) {
       if (e.getGpsGeom_id() == old_id) {
         e.setGpsGeom_id(new_id);
       }
     }
   }
 }
示例#19
0
	/**
	 *  普通版填写包的公共部分
	 * @param root	开始节点
	 * @param map	参数map
	 * @param sCycName	循环节点名
	 * @return
	 */
	public Element writeptPublicNode(Element root,HashMap map,String sCycName)
	{
		Element node=null;
		try
		{
			String sName="";
			String sValue="";
			List list=root.getChildren();
			for(int i=0;i<list.size();i++)
			{
				node=(Element)list.get(i);
				sName=node.getName();
				sName=sName.trim();
				sValue=(String)map.get(sName);
				//System.err.println("sName:"+sName+":"+sValue);
				if(sCycName.equals(sName)&&(root.getName()).trim().equals("ReqParamSet"))
				{
					//System.err.println("find cyc node:"+sName );
					return node;
				}
				else if(sValue!=null && !"".equals(sValue) )
					node.setText(sValue);
				node=writeptPublicNode(node,map,sCycName);
			}
		}catch(Exception ex)
		{
			ex.printStackTrace();
			System.err.println("error:"+ex.getMessage());
		}
		return node;
	}
示例#20
0
 public void setElement(int number, int data) {
   if (number >= getVectorSize() || number < MIN_VECTOR_SIZE)
     throw new VectorIndexOutOfBoundsException();
   Element current = head;
   for (int i = -1; i < number; i++) current = current.getNext();
   current.setField(data);
 }
 /**
  * Adds a template to a xml file.
  *
  * @param language template that should be added.
  * @return Element
  */
 private Element createLanguage(Language language) {
   Element newLanguage = this.factory.createLanguageElement(language);
   Element languages = this.getLanguagesElement();
   languages.appendChild(newLanguage);
   writeDocument();
   return newLanguage;
 }
示例#22
0
  /** 打开查询结果 */
  public static String[] openQuery(Hashtable params) {

    JParamObject PO = new JParamObject();

    for (Enumeration e = params.keys(); e.hasMoreElements(); ) {
      String key = (String) e.nextElement();
      String val = (String) params.get(key);
      PO.SetValueByParamName(key, val);
    }
    String[] queryResult = new String[2];
    JResponseObject RO =
        (JResponseObject)
            JActiveDComDM.AbstractDataActiveFramework.InvokeObjectMethod(
                "DataReport", "OpenQuery", PO, "");
    String XMLStr = (String) RO.ResponseObject;
    if (RO != null && RO.ResponseObject != null) {
      XMLStr = (String) RO.ResponseObject;
      JXMLBaseObject XMLObj = new JXMLBaseObject(XMLStr);
      Element queryElmt = XMLObj.GetElementByName("Query");
      // 格式
      queryResult[0] = queryElmt.getAttributeValue("QueryFormat");
      // 数据
      queryResult[0] = queryElmt.getAttributeValue("QueryData");
    }
    return queryResult;
  }
示例#23
0
  private void gatherNamespaces(Element element, List<URI> namespaceSources) throws SAXException {
    NamedNodeMap attributes = element.getAttributes();
    int attributeCount = attributes.getLength();

    for (int i = 0; i < attributeCount; i++) {
      Attr attribute = (Attr) attributes.item(i);
      String namespace = attribute.getNamespaceURI();

      if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace)) {
        try {
          namespaceSources.add(new URI(attribute.getValue()));
        } catch (URISyntaxException e) {
          throw new SAXException(
              "Cannot validate this document with this class.  Namespaces must be valid URIs.  Found Namespace: '"
                  + attribute.getValue()
                  + "'.",
              e);
        }
      }
    }

    NodeList childNodes = element.getChildNodes();
    int childCount = childNodes.getLength();
    for (int i = 0; i < childCount; i++) {
      Node child = childNodes.item(i);

      if (child.getNodeType() == Node.ELEMENT_NODE) {
        gatherNamespaces((Element) child, namespaceSources);
      }
    }
  }
  private void handleEmbeddedType(Element element, Set<TypeElement> elements) {
    TypeMirror type = element.asType();
    if (element.getKind() == ElementKind.METHOD) {
      type = ((ExecutableElement) element).getReturnType();
    }
    String typeName = type.toString();

    if (typeName.startsWith(Collection.class.getName())
        || typeName.startsWith(List.class.getName())
        || typeName.startsWith(Set.class.getName())) {
      type = ((DeclaredType) type).getTypeArguments().get(0);

    } else if (typeName.startsWith(Map.class.getName())) {
      type = ((DeclaredType) type).getTypeArguments().get(1);
    }

    TypeElement typeElement = typeExtractor.visit(type);

    if (typeElement != null
        && !TypeUtils.hasAnnotationOfType(typeElement, conf.getEntityAnnotations())) {
      if (!typeElement.getQualifiedName().toString().startsWith("java.")) {
        elements.add(typeElement);
      }
    }
  }
  public ArrayList<String> parseXML() throws Exception {
    ArrayList<String> ret = new ArrayList<String>();

    handshake();

    URL url =
        new URL(
            "http://mangaonweb.com/page.do?cdn="
                + cdn
                + "&cpn=book.xml&crcod="
                + crcod
                + "&rid="
                + (int) (Math.random() * 10000));
    String page = DownloaderUtils.getPage(url.toString(), "UTF-8", cookies);

    DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
    DocumentBuilder builder = factory.newDocumentBuilder();
    InputSource is = new InputSource(new StringReader(page));
    Document d = builder.parse(is);
    Element doc = d.getDocumentElement();

    NodeList pages = doc.getElementsByTagName("page");
    total = pages.getLength();
    for (int i = 0; i < pages.getLength(); i++) {
      Element e = (Element) pages.item(i);
      ret.add(e.getAttribute("path"));
    }

    return (ret);
  }
示例#26
0
  /*
   *  We need to know if the caret is currently positioned on the line we
   *  are about to paint so the line number can be highlighted.
   */
  private boolean isCurrentLine(int rowStartOffset) {
    int caretPosition = component.getCaretPosition();
    Element root = component.getDocument().getDefaultRootElement();

    if (root.getElementIndex(rowStartOffset) == root.getElementIndex(caretPosition)) return true;
    else return false;
  }
示例#27
0
 @Override
 public Element clone() throws CloneNotSupportedException {
   Element c = (Element) super.clone();
   // key copied by clone
   c.value = this.value.clone();
   return c;
 }
 private void writeContent(final int end, final List childElements, final int depth)
     throws IOException {
   // sets index to end
   for (final Iterator i = childElements.iterator(); i.hasNext(); ) {
     final Element element = (Element) i.next();
     final int elementBegin = element.begin;
     if (elementBegin >= end) break;
     if (indentAllElements) {
       writeText(elementBegin, depth);
       writeElement(element, depth, end, false, false);
     } else {
       if (inlinable(element)) continue; // skip over elements that can be inlined.
       writeText(elementBegin, depth);
       final String elementName = element.getName();
       if (elementName == HTMLElementName.PRE || elementName == HTMLElementName.TEXTAREA) {
         writeElement(element, depth, end, true, true);
       } else if (elementName == HTMLElementName.SCRIPT) {
         writeElement(element, depth, end, true, false);
       } else {
         writeElement(
             element,
             depth,
             end,
             false,
             !removeLineBreaks && containsOnlyInlineLevelChildElements(element));
       }
     }
   }
   writeText(end, depth);
 }
示例#29
0
  /**
   * Returns a sibling element that matches a given definition, or <tt>null</tt> if no match is
   * found.
   *
   * @param sibling the sibling DOM element to begin the search
   * @param target the node to search for
   * @return the matching element, or <tt>null</tt> if not found
   */
  public static Element findSibling(Element sibling, XmlNode target) {
    String xmlName = target.getLocalName();
    String xmlNamespace = target.getNamespace();

    Node node = sibling;
    if (node == null) {
      return null;
    }

    while ((node = node.getNextSibling()) != null) {
      if (node.getNodeType() != Node.ELEMENT_NODE) {
        continue;
      }
      Element element = (Element) node;
      if (!element.getLocalName().equals(xmlName)) {
        continue;
      }
      if (target.isNamespaceAware()) {
        String ns = element.getNamespaceURI();
        if (ns == null) {
          if (xmlNamespace != null) {
            continue;
          }
        } else {
          if (!ns.equals(xmlNamespace)) {
            continue;
          }
        }
      }
      return element;
    }
    return null;
  }
示例#30
0
  public static Element[] filterChildElements(Element parent, String ns, String lname) {
    /*
    way too noisy
            if (LOGGER.isDebugEnabled()) {
                StringBuilder buf = new StringBuilder(100);
                buf.append("XmlaUtil.filterChildElements: ");
                buf.append(" ns=\"");
                buf.append(ns);
                buf.append("\", lname=\"");
                buf.append(lname);
                buf.append("\"");
                LOGGER.debug(buf.toString());
            }
    */

    List<Element> elems = new ArrayList<Element>();
    NodeList nlst = parent.getChildNodes();
    for (int i = 0, nlen = nlst.getLength(); i < nlen; i++) {
      Node n = nlst.item(i);
      if (n instanceof Element) {
        Element e = (Element) n;
        if ((ns == null || ns.equals(e.getNamespaceURI()))
            && (lname == null || lname.equals(e.getLocalName()))) {
          elems.add(e);
        }
      }
    }
    return elems.toArray(new Element[elems.size()]);
  }