Package org.w3c.dom

Examples of org.w3c.dom.Attr


            }
           
            this.add("]}");
            return true;
    }else if(node instanceof Attr){
      Attr atr = (Attr)node;
      return this.add(atr.getName(),atr.getValue(),null,false, null);
    }
    return false;
  }
View Full Code Here


        Map<String, Object> params = new HashMap<String, Object>();
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element hi = doc.createElement("hi");
        Element ho = doc.createElement("ho");
        hi.appendChild(ho);
        Attr attr = doc.createAttribute("value");
        ho.setAttributeNode(attr);
        attr.setValue("a");
        params.put("x", hi);
        params.put("y", "Second");
        ProcessInstance processInstance = ksession.startProcess("com.sample.test", params);
        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    }
View Full Code Here

        Map<String, Object> params = new HashMap<String, Object>();
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element hi = doc.createElement("hi");
        Element ho = doc.createElement("ho");
        hi.appendChild(ho);
        Attr attr = doc.createAttribute("value");
        ho.setAttributeNode(attr);
        attr.setValue("a");
        params.put("x", hi);
        params.put("y", "Second");
        ProcessInstance processInstance = ksession.startProcess("com.sample.test", params);
        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    }
View Full Code Here

        Map<String, Object> params = new HashMap<String, Object>();
        Document doc = DocumentBuilderFactory.newInstance().newDocumentBuilder().newDocument();
        Element hi = doc.createElement("hi");
        Element ho = doc.createElement("ho");
        hi.appendChild(ho);
        Attr attr = doc.createAttribute("value");
        ho.setAttributeNode(attr);
        attr.setValue("a");
        params.put("x", hi);
        params.put("y", "Second");
        ProcessInstance processInstance = ksession.startProcess("com.sample.test", params);
        assertTrue(processInstance.getState() == ProcessInstance.STATE_COMPLETED);
    }
View Full Code Here

                return e.getAttribute(attrName);
            } else {
                NamedNodeMap attrs = e.getAttributes();
                int l = attrs.getLength();
                for (int i = 0; i < l; i++) {
                    Attr attr = (Attr)attrs.item(i);
                    if (attrName.equals(attr.getLocalName())) {
                        return attr.getValue();
                    }
                }
               
                return "";
            }
View Full Code Here

        // accumulate namespace declarations from this element
        ArrayList nss = null;
        NamedNodeMap attrs = element.getAttributes();
        int size = attrs.getLength();
        for (int i = 0; i < size; i++) {
            Attr attr = (Attr)attrs.item(i);
            if (XMLNS_NAMESPACE.equals(attr.getNamespaceURI())) {
               
                // found namespace declaration, convert to simple prefix
                String declpref = attr.getLocalName();
                if ("xmlns".equals(declpref)) {
                    declpref = null;
                }
                String decluri = attr.getValue();
                if (findNamespaceIndex(declpref, decluri) < 0) {
                    if (nss == null) {
                        nss = new ArrayList();
                    }
                    addNamespace(declpref, decluri, nss);
                }
            }
        }
       
        // check that namespace used by element name is defined
        String prefix = element.getPrefix();
        String uri = element.getNamespaceURI();
        int nsi = findNamespaceIndex(prefix, uri);
        if (nsi < 0) {
            if (nss == null) {
                nss = new ArrayList();
            }
            addNamespaceUnique(prefix, uri, nss);
        }
       
        // check that every namespace used by an attribute is defined
        for (int i = 0; i < size; i++) {
            Attr attr = (Attr)attrs.item(i);
            if (!XMLNS_NAMESPACE.equals(attr.getNamespaceURI())) {
               
                // found normal attribute, check namespace and prefix
                String attruri = attr.getNamespaceURI();
                if (attruri != null) {
                    String attrpref = attr.getPrefix();
                    if (findNamespaceIndex(attrpref, attruri) < 0) {
                        if (nss == null) {
                            nss = new ArrayList();
                        }
                        addNamespaceUnique(attrpref, attruri, nss);
                    }
                }
            }
        }
       
        // check for default namespace setting
        int defind = -1;
        String defuri = null;
        if (nss != null) {
            for (int i = 0; i < nss.size(); i += 2) {
                if ("".equals(nss.get(i))) {
                    defind = i / 2;
                    defuri = (String)nss.get(i+1);
                }
            }
        }
       
        // check for namespace declarations required
        String[] uris = null;
        String name = element.getLocalName();
        if (name == null) {
            name = element.getTagName();
        }
        if (nss == null) {
            m_xmlWriter.startTagOpen(nsi, name);
        } else {
            int base = getNextNamespaceIndex();
            if (defind >= 0) {
                m_defaultNamespaceIndex = base + defind;
                m_defaultNamespaceURI = defuri;
            }
            int length = nss.size() / 2;
            uris = new String[length];
            int[] nums = new int[length];
            String[] prefs = new String[length];
            for (int i = 0; i < length; i++) {
                prefs[i] = (String)nss.get(i*2);
                uris[i] = (String)nss.get(i*2+1);
                nums[i] = base + i;
                if (nsi < 0 && uri.equals(uris[i])) {
                    if ((prefix == null && prefs[i] == "") ||
                        (prefix != null && prefix.equals(prefs[i]))) {
                        nsi = base + i;
                    }
                }
            }
            m_xmlWriter.pushExtensionNamespaces(uris);
            m_xmlWriter.startTagNamespaces(nsi, name, nums, prefs);
            if (defind >= 0) {
                m_defaultNamespaceIndex = defind;
                m_defaultNamespaceURI = defuri;
            }
        }
       
        // add attributes if present
        for (int i = 0; i < size; i++) {
            Attr attr = (Attr)attrs.item(i);
            if (!XMLNS_NAMESPACE.equals(attr.getNamespaceURI())) {
                int index = 0;
                String apref = attr.getPrefix();
                if (apref != null) {
                    index = findNamespaceIndex(apref, attr.getNamespaceURI());
                }
                String aname = attr.getLocalName();
                if (aname == null) {
                    aname = attr.getName();
                }
                m_xmlWriter.addAttribute(index, aname, attr.getValue());
            }
        }
       
        // check for content present
        NodeList nodes = element.getChildNodes();
View Full Code Here

      tag.append(((Element)_node).getTagName());
      NamedNodeMap list = _node.getAttributes();
      if (list != null) {
        int length = list.getLength();
        for(int i=0; i<length; i++) {
          Attr attr = (Attr)list.item(i);
          tag.append(' ');
          tag.append(attr.getName());
          String value = attr.getValue();
          if (value != null) {
            tag.append('=');
            tag.append('"');
            tag.append(anvil.util.Conversions.encodeEntities(value));
            tag.append('"');
View Full Code Here

    if (_type == Node.ELEMENT_NODE) {
      NamedNodeMap map = _node.getAttributes();
      int length = map.getLength();
      Array attributes = new Array(length);
      for(int i=0; i<length; i++) {
        Attr attr = (Attr)map.item(i);
        attributes.append(attr.getName(), Any.create(attr.getValue()));
      }
      return attributes;
    } else {
      return NULL;
    }
View Full Code Here

        Element e = doc.createElementNS("urn:test","root");
        e.setAttribute("xmlns", "urn:test");
        doc.appendChild(e);
        e.setAttribute("att1", "value1");
       
        Attr attr = doc.createAttributeNS("urn:test2","att2");
        attr.setValue("value2");
        attr.setPrefix("p");
       
        e.setAttribute("xmlns:p", "urn:test2");
       
        e.setAttributeNode(attr);
        DOMUtils.writeXml(doc,System.out);
View Full Code Here

      // w3c conforming code:
      NamedNodeMap attributes = node.getAttributes();
      if (attributes != null && attributes.getLength() > 0) {
         int attributeCount = attributes.getLength();
         for (int i = 0; i < attributeCount; i++) {
            Attr attribute = (Attr)attributes.item(i);
            if (attribute.getNodeName().equals("oid")) {
               String val = attribute.getNodeValue();
               return val;
            }
         }
      }
View Full Code Here

TOP

Related Classes of org.w3c.dom.Attr

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.