Package org.w3c.dom

Examples of org.w3c.dom.NodeList


      // give everyone an initial balance of $50
      Double initialBalance = new Double(50);
      // iterate over the accounts
      Map<String, Double> accounts = new HashMap<String, Double>();
      Element accountsElem = accountsDocument.getDocumentElement();
      NodeList accountElems = accountsElem.getElementsByTagName("account");
      for (int i = 0, n = accountElems.getLength(); i < n; i++) {
        Element accountElem = (Element) accountElems.item(i);
        // create account, assign initial balance
        String customerName = accountElem.getAttribute("holder");
        accounts.put(customerName, initialBalance);
      }
      return accounts;
View Full Code Here


        }
    }

    public void fillDependencies(Collection<File> files, Document doc) {
        Element rootElement = Helper.getFirstElement(doc.getElementsByTagName("dependencies"));
        NodeList nodeList = rootElement.getElementsByTagName("dependency");
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            if (n.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element element = (Element) n;
            boolean include = true;
View Full Code Here

        Element rootElement = Helper.getFirstElement(doc.getElementsByTagName("properties"));
        if (rootElement == null) {
            return;
        }

        NodeList nodeList = rootElement.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node n = nodeList.item(i);
            if (n.getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element element = (Element) n;
            properties.put(element.getNodeName(), element.getTextContent());
View Full Code Here

    protected void endNode(final String name, final StringBuilder xmlDump) {
        xmlDump.append("    </" + name + ">" + EOL);
    }
   
    protected void handleScript(final ExtendedNodeImpl node, final Element element, String type) {
        NodeList nodeList = element.getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
          if (nodeList.item(i) instanceof Element) {
            Element xmlNode = (Element) nodeList.item(i);
            String nodeName = xmlNode.getNodeName();
            if (nodeName.equals("extensionElements")) {
                  NodeList subNodeList = xmlNode.getChildNodes();
                  for (int j = 0; j < subNodeList.getLength(); j++) {
                    org.w3c.dom.Node subXmlNode = subNodeList.item(j);
                    if ((type + "-script").equals(subXmlNode.getNodeName())) {
                List<DroolsAction> actions = node.getActions(type);
                if (actions == null) {
                  actions = new ArrayList<DroolsAction>();
                      node.setActions(type, actions);
View Full Code Here

    public static DroolsAction extractScript(Element xmlNode) {
      String dialect = "mvel";
      if ("http://www.java.com/java".equals(xmlNode.getAttribute("scriptFormat"))) {
        dialect = "java";
      }
    NodeList subNodeList = xmlNode.getChildNodes();
        for (int j = 0; j < subNodeList.getLength(); j++) {
          if (subNodeList.item(j) instanceof Element) {
            Element subXmlNode = (Element) subNodeList.item(j);
            if ("script".equals(subXmlNode.getNodeName())) {
              String consequence = subXmlNode.getTextContent();
              DroolsConsequenceAction action = new DroolsConsequenceAction(dialect, consequence);
              return action;
            }
View Full Code Here

        return parse(doc);
    }

    public List<JavaOneInterval> parse(Document doc) {
        List<JavaOneInterval> eventList = new ArrayList<JavaOneInterval>();
        NodeList nl = doc.getElementsByTagName("tr");
        for (int i = 0; i < nl.getLength(); i++) {
            if (nl.item(i).getNodeType() != Node.ELEMENT_NODE) {
                continue;
            }
            Element el = (Element) nl.item(i);
            NodeList columnNodeList = el.getElementsByTagName("td");
            JavaOneInterval event = new JavaOneInterval();
            eventList.add(event);
            for (int jj = 0; jj < columnNodeList.getLength(); jj++) {
                if (columnNodeList.item(jj).getNodeType() != Node.ELEMENT_NODE) {
                    continue;
                }
                Element columnElement = (Element) columnNodeList.item(jj);
                switch (jj) {
                    case 0:
                        event.setId(columnElement.getTextContent().trim());
                        break;
                    case 1:
                        event.setDescription(columnElement.getTextContent().trim());
                        break;
                    case 2:
                        event.setType(columnElement.getTextContent().trim());
                        break;
                    case 3:
                        event.setSpeakers(columnElement.getTextContent().trim());
                        break;
                    case 4:
                        NodeList timeNodes = columnElement.getChildNodes();
                        for (int j = 0; j < timeNodes.getLength(); j++) {
                            if (timeNodes.item(j) != null) {
                                String dateStr = timeNodes.item(j).getTextContent().trim();

                                if (dateStr.contains("June")) {

                                    int day = Integer.parseInt(dateStr.split("      ")[1]);

                                    String timeStrs[] = timeNodes.item(j + 2).getTextContent().trim().split(" - ");
                                    String startStr = timeStrs[0];
                                    String endStr = timeStrs[1];
                                    int index = startStr.indexOf(":");
                                    int index2 = startStr.indexOf(" ");
                                    int startHour = Integer.parseInt(startStr.substring(0, index));
View Full Code Here

          }
      this.add('{');
            this.add('"');
            this.add(elem.getTagName());
            this.add("\":[");
            NodeList childs = elem.getChildNodes();
            int childLength = childs.getLength();
            for(int c =0; c < childLength; c++){
              hasData = xmlNode(childs.item(c),null, hasData && c != 0);
            }
           
            this.add("]}");
            return true;
    }else if(node instanceof Attr){
View Full Code Here

                    ObjectName connectionFactoryOName = new ObjectName("jboss.jca:service=ManagedConnectionFactory,name=" + resource.getName());
                    Element elm = (Element) server.getAttribute(connectionFactoryOName, "ManagedConnectionFactoryProperties");

                    if (elm != null) {
                        NodeList nl = elm.getChildNodes();
                        for (int i = 0; i < nl.getLength(); i++) {
                            Node n = nl.item(i);
                            Node na = n.getAttributes().getNamedItem("name");
                            if (na != null) {
                                if ("ConnectionURL".equals(na.getNodeValue())) {
                                    dsInfo.setJdbcURL(n.getFirstChild().getNodeValue());
                                }
View Full Code Here

   
    appendElement(taglib, "tlibversion", "4.0");
    appendElement(taglib, "jspversion", "2.0");
    appendElement(taglib, "shortname", "WebTML");
   
    NodeList groups = tml.getElementsByTagName("attributeGroup");
    for(int i = 0; i < groups.getLength(); i++) {
      Element group = (Element) groups.item(i);
      String name = childText(group, "name");
      attributeGroups.put(name, group.getElementsByTagName("attribute"));
    }
   
    NodeList tags = tml.getElementsByTagName("tag");
    for(int i = 0; i < tags.getLength(); i++) {
      Element tmlTag = (Element) tags.item(i);
      String name = childText(tmlTag, "name");
      copyTag(name, tmlTag, appendElement(taglib, "tag"));
      Element aliases = (Element) tmlTag.getElementsByTagName("aliases").item(0);
      NodeList aliasNames = aliases.getElementsByTagName("string");
      for(int j = 0; j < aliasNames.getLength(); j++) {
        String aliasName = aliasNames.item(j).getTextContent();
        copyTag(aliasName, tmlTag, appendElement(taglib, "tag"));
      }
    }
   
    TransformerFactory transformerFactory = TransformerFactory.newInstance();
View Full Code Here

    appendElement(tldTag, "name", tagName);
    appendElement(tldTag, "tagclass", childText(tmlTag, "tagclass"));
    appendElement(tldTag, "bodycontent", childText(tmlTag, "bodycontent"));
    appendElement(tldTag, "info", childText(tmlTag, "description"));
   
    NodeList attributes = tmlTag.getElementsByTagName("attribute");
    for(int i = 0; i < attributes.getLength(); i++) {
      Element attr = (Element) attributes.item(i);
      copyAttribute(attr, appendElement(tldTag, "attribute"));
    }
    NodeList groups = ((Element) tmlTag.getElementsByTagName("attributeGroups").item(0)).getElementsByTagName("string");
    for(int i = 0; i < groups.getLength(); i++) {
      String name = groups.item(i).getTextContent();
      NodeList attributes2 = this.attributeGroups.get(name);
      for(int j = 0; j < attributes2.getLength(); j++) {
        Element attr = (Element) attributes2.item(j);
        copyAttribute(attr, appendElement(tldTag, "attribute"));
      }     
    }
    Element sorucelineAttr = appendElement(tldTag, "attribute");
    appendElement(sorucelineAttr, "name", "sourceline");
View Full Code Here

TOP

Related Classes of org.w3c.dom.NodeList

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.