Package org.w3c.dom

Examples of org.w3c.dom.Node


            return false;
        }

        private void processDatasetsInternal(Node n) {
            HashMap ss = new HashMap();
            Node n2 = n.getFirstChild();
            while (n2 != null) {
                if (n2.getNodeType() == Node.ELEMENT_NODE) {
                    String s = escapeSom(n2.getLocalName());
                    Integer i = (Integer)ss.get(s);
                    if (i == null)
                        i = new Integer(0);
                    else
                        i = new Integer(i.intValue() + 1);
                    ss.put(s, i);
                    if (hasChildren(n2)) {
                        stack.push(s + "[" + i.toString() + "]");
                        processDatasetsInternal(n2);
                        stack.pop();
                    }
                    else {
                        stack.push(s + "[" + i.toString() + "]");
                        String unstack = printStack();
                        order.add(unstack);
                        inverseSearchAdd(unstack);
                        name2Node.put(unstack, n2);
                        stack.pop();
                    }
                }
                n2 = n2.getNextSibling();
            }
        }
View Full Code Here


         * Gets the field type as described in the <CODE>template</CODE> section of the XFA.
         * @param s the exact template name
         * @return the field type or <CODE>null</CODE> if not found
         */
        public String getFieldType(String s) {
            Node n = (Node)name2Node.get(s);
            if (n == null)
                return null;
            if (n.getLocalName().equals("exclGroup"))
                return "exclGroup";
            Node ui = n.getFirstChild();
            while (ui != null) {
                if (ui.getNodeType() == Node.ELEMENT_NODE && ui.getLocalName().equals("ui")) {
                    break;
                }
                ui = ui.getNextSibling();
            }
            if (ui == null)
                return null;
            Node type = ui.getFirstChild();
            while (type != null) {
                if (type.getNodeType() == Node.ELEMENT_NODE && !(type.getLocalName().equals("extras") && type.getLocalName().equals("picture"))) {
                    return type.getLocalName();
                }
                type = type.getNextSibling();
            }
            return null;
        }
View Full Code Here

        private void processTemplate(Node n, HashMap ff) {
            if (ff == null)
                ff = new HashMap();
            HashMap ss = new HashMap();
            Node n2 = n.getFirstChild();
            while (n2 != null) {
                if (n2.getNodeType() == Node.ELEMENT_NODE) {
                    String s = n2.getLocalName();
                    if (s.equals("subform")) {
                        Node name = n2.getAttributes().getNamedItem("name");
                        String nn = "#subform";
                        boolean annon = true;
                        if (name != null) {
                            nn = escapeSom(name.getNodeValue());
                            annon = false;
                        }
                        Integer i;
                        if (annon) {
                            i = new Integer(anform);
                            ++anform;
                        }
                        else {
                            i = (Integer)ss.get(nn);
                            if (i == null)
                                i = new Integer(0);
                            else
                                i = new Integer(i.intValue() + 1);
                            ss.put(nn, i);
                        }
                        stack.push(nn + "[" + i.toString() + "]");
                        ++templateLevel;
                        if (annon)
                            processTemplate(n2, ff);
                        else
                            processTemplate(n2, null);
                        --templateLevel;
                        stack.pop();
                    }
                    else if (s.equals("field") || s.equals("exclGroup")) {
                        Node name = n2.getAttributes().getNamedItem("name");
                        if (name != null) {
                            String nn = escapeSom(name.getNodeValue());
                            Integer i = (Integer)ff.get(nn);
                            if (i == null)
                                i = new Integer(0);
                            else
                                i = new Integer(i.intValue() + 1);
                            ff.put(nn, i);
                            stack.push(nn + "[" + i.toString() + "]");
                            String unstack = printStack();
                            order.add(unstack);
                            inverseSearchAdd(unstack);
                            name2Node.put(unstack, n2);
                            stack.pop();
                        }
                    }
                    else if (!dynamicForm && templateLevel > 0 && s.equals("occur")) {
                        int initial = 1;
                        int min = 1;
                        int max = 1;
                        Node a = n2.getAttributes().getNamedItem("initial");
                        if (a != null)
                            try{initial = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
                        a = n2.getAttributes().getNamedItem("min");
                        if (a != null)
                            try{min = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
                        a = n2.getAttributes().getNamedItem("max");
                        if (a != null)
                            try{max = Integer.parseInt(a.getNodeValue().trim());}catch(Exception e){}
                        if (initial != min || min != max)
                            dynamicForm = true;
                    }
                }
                n2 = n2.getNextSibling();
View Full Code Here

        List nodes = parm.getDocumentation();
        if (nodes != null) {
            AnnotationElement anno = new AnnotationElement();
            DocumentationElement doc = new DocumentationElement();
            for (Iterator iter = nodes.iterator(); iter.hasNext();) {
                Node node = (Node)iter.next();
                doc.addContent(node);
            }
            anno.getItemsList().add(doc);
            elem.setAnnotation(anno);
        }
View Full Code Here

        if (nodeList.getLength() == 0) {
            return false;
        }
        nodeList = nodeList.item(0).getChildNodes();
        for (int i = 0; i < nodeList.getLength(); i++) {
            Node node = nodeList.item(i);
            if (node.getNodeType() == Node.ELEMENT_NODE) {
                visitor.readFromNode(node);
            }
        }
        return true;
    }
View Full Code Here

        }
       
        // unmarshal content to document model
        m_unmarshalContext = (UnmarshallingContext)ictx;
        try {
            Node node;
            while ((node = unmarshalNode()) != null) {
                list.add(node);
            }
            if (created && list.isEmpty()) {
                return null;
View Full Code Here

                    if (item instanceof DocumentationElement) {
                        DocumentationElement doc = (DocumentationElement)item;
                        List contents = doc.getContent();
                        if (contents != null) {
                            for (Iterator iter = contents.iterator(); iter.hasNext();) {
                                Node node = (Node)iter.next();
                                DOMSource source = new DOMSource(node);
                                StreamResult result = new StreamResult(writer);
                                try {
                                    s_transformer.transform(source, result);
                                } catch (TransformerException e) {
View Full Code Here

   */
  public static String extractTextChildren(Element parentNode) {
    NodeList childNodes = parentNode.getChildNodes();
    String result = new String();
    for (int i = 0; i < childNodes.getLength(); i++) {
      Node node = childNodes.item(i);
      if (node.getNodeType() == Node.TEXT_NODE) {
        result += node.getNodeValue();
      }
    }
    return result;
  }
View Full Code Here

   */
  public static Element getChild(Element parentNode, String nodeName) {
    NodeList childNodes = parentNode.getChildNodes();

    for (int i = 0; i < childNodes.getLength(); i++) {
      Node node = childNodes.item(i);
      if (node.getNodeType() == Node.ELEMENT_NODE && nodeName.equals(node.getNodeName())) {
        return (Element) node;
      }
    }
    return null;
  }
View Full Code Here

        }
       
        // unmarshal content to document model
        m_unmarshalContext = (UnmarshallingContext)ictx;
        try {
            Node node;
            while ((node = unmarshalNode()) != null) {
                frag.appendChild(node);
            }
            if (created && !frag.hasChildNodes()) {
                return null;
View Full Code Here

TOP

Related Classes of org.w3c.dom.Node

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.