Examples of NamedNodeMap


Examples of org.w3c.dom.NamedNodeMap

            return e.getAttribute(attrName);
        } else if (namespaceURI == null) {
            if (e.getLocalName() == null) { // No namespaces
                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();
                    }
                }
               
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

    protected void marshalElement(Element element)
        throws JiBXException, IOException {
       
        // 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());
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

    switch(_type) {
    case Node.ELEMENT_NODE:
      StringBuffer tag = new StringBuffer();
      tag.append('<');
      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('=');
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

  /// @return array of attributes for this node. Attributes are mapped
  ///    into array with their respective names.
  public Any m_getAttributes()
  {
    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

Examples of org.w3c.dom.NamedNodeMap

  /// @synopsis array getEntities()
  /// @return array of entities of <i>document type</i> node
  public Any m_getEntities()
  { 
    if (_type == Node.DOCUMENT_TYPE_NODE) {
      NamedNodeMap map = ((DocumentType)_node).getEntities();
      int length = map.getLength();
      Array entities = new Array(length);
      for(int i=0; i<length; i++) {
        Node entity = map.item(i);
        if (entity.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
          entities.append(((DocumentType)entity).getName(), new AnyNode(entity));
        }
      }
      return entities;
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

  /// @synopsis array getNotations()
  /// @return array of notations of <i>document type</i> node
  public Any m_getNotations()
  {
    if (_type == Node.DOCUMENT_TYPE_NODE) {
      NamedNodeMap map = ((DocumentType)_node).getNotations();
      int length = map.getLength();
      Array notations = new Array(length);
      for(int i=0; i<length; i++) {
        Node entity = map.item(i);
        if (entity.getNodeType() == Node.DOCUMENT_TYPE_NODE) {
          notations.append(((DocumentType)entity).getName(), new AnyNode(entity));
        }
      }
      return notations;
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

  public void modelChanged(ModelChangeEvent e) throws GUIException {
    MapChangeEvent event = (MapChangeEvent) e;

    if (event.getKey().equals("value")) {
      if (propertyNode.getNodeName().equals("property")) {
        NamedNodeMap map = propertyNode.getAttributes();
        for (int i = 0; i < map.getLength(); i++) {
          String name = map.item(i).getNodeName();
          if (!name.equals("name") && !name.equals("type")) {
            propertyNode.removeAttribute(map.item(i).getNodeName());
          }
        }

        if (!propertyNode.getAttribute("name").equals("border")) {
          NodeList children = propertyNode.getChildNodes();
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

    activateType(dataModel.getValue("type").toString());
  }

  protected void doOK() throws GUIException {
    NamedNodeMap map = anchorNode.getAttributes();
    for (int i = 0; i < map.getLength(); i++) {
      anchorNode.removeAttribute(map.item(i).getNodeName());
    }

    String type = dataModel.getValue("type").toString();

    if (!type.equals("none")) {
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

      final String off = "\n" + offset;

      if (node instanceof Element) {
         String name = node.getNodeName();
         // String value = node.getNodeValue();
         NamedNodeMap attrs = node.getAttributes();
         StringBuffer buf = new StringBuffer(128);
         StringBuffer buf1 = new StringBuffer(50);

         buf.append(off).append("<").append(name);
         if (attrs != null && attrs.getLength() > 0) {
            for (int i=0; i < attrs.getLength(); i++) {
               Node attr = attrs.item(i);
               buf.append(" ").append(attr.getNodeName()).append("='").append(attr.getNodeValue()).append("'");
            }
         }
         boolean hasChilds = node.hasChildNodes();
         if (!hasChilds) {
View Full Code Here

Examples of org.w3c.dom.NamedNodeMap

        assertEquals( "element.getNodeName()", name, element.getNodeName() );

        final NodeList nodeList = element.getChildNodes();
        assertEquals( "nodeList.getLength()", 0, nodeList.getLength() );

        final NamedNodeMap attributes = element.getAttributes();
        assertEquals( "attributes.getLength()", 0, attributes.getLength() );
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.