Package org.w3c.dom

Examples of org.w3c.dom.NamedNodeMap


   private static void infoNode(XMLNode n, String xpath){
        try {
          showExemple(xpath + "text()");

          //parcoure des ATTRIBUE
          NamedNodeMap nnm =  n.getAttributes();
          for (int i = 0; i < nnm.getLength(); i++) {
            XMLAttr att = (XMLAttr) nnm.item(i);
            showExemple(xpath + "@"+att.getExpandedName());
          }
         

          //parcoure des nodes
View Full Code Here


    String tagName = "";

    try
    {
      Document configForQBXML;
      NamedNodeMap attr;

      Class classCV[] = new Class[1];
      Class argumentType[] = new Class[1];

      Object arguments[] = new Object[1];

      String className = getValueOfNodeByTagName(configXML, TAG_VONAME);

      String typeArg = "";
      String value = "";

      NodeList listItem = configXML.getChildNodes();
      NodeList tmpNodeList = null;

      int length = listItem.getLength();

      classCV[0] = Class.forName(className);
      objectCV = classCV[0].newInstance();

      Method method = null;
      setType(objectCV, configXML, className);

      for (int i = 0; i < length; i++)
      {
        tagName = listItem.item(i).getNodeName();

        if (tagName.equals("#text") || !listItem.item(i).hasAttributes())
        {
          continue;
        }

        attr = listItem.item(i).getAttributes();

        if (attr.getNamedItem("aatocv") != null)
        {
          tmpNodeList = getDocumentFromString(xml.toString()).getElementsByTagName(tagName);

          if (tmpNodeList.getLength() != 0)
          {
            setAAtoCV(objectCV, attr, tmpNodeList, classCV, tagName);
          }
          continue;
        }

        if (attr.getNamedItem("xml") != null)
        {
          configForQBXML = getDocumentFromString(getDocumentFromString(attr.getNamedItem("xml").getNodeValue()).getElementsByTagName(attr.getNamedItem("tag").getNodeValue()).item(0).toString());
          tmpNodeList = getDocumentFromString(xml.toString()).getElementsByTagName(tagName);

          if (tmpNodeList.item(0) != null)
          {
            forward(objectCV, attr, tmpNodeList.item(0), classCV, className, configForQBXML);
          }
          continue;
        }

        value = getValueOfNodeByTagName(xml, tagName);

        if (value == null)
          continue;

        typeArg = attr.getNamedItem("type").getNodeValue();

        argumentType[0] = getArgType(typeArg);
        arguments[0] = getObjectByName(typeArg, value);

        method = classCV[0].getMethod(attr.getNamedItem("set").getNodeValue(), argumentType);
        method.invoke(objectCV, arguments);
      }
    } catch (Exception e)
    {
      logger.error("QBXMLTag = <" + tagName + "> ********* Error while loading up/down classes : ", e);
View Full Code Here

        tagName = listItem.item(i).getNodeName();

        if (tagName.equals("#text") || !listItem.item(i).hasAttributes())
          continue;

        NamedNodeMap attr = listItem.item(i).getAttributes();
        typeArg = attr.getNamedItem("type").getNodeValue();
        argumentType[0] = getArgType(typeArg);

        value = getValueOfNodeByTagName(qbXML, tagName);

        arguments[0] = getObjectByName(typeArg, value);

        method = classCV[0].getMethod(attr.getNamedItem("set").getNodeValue(), argumentType);
        method.invoke(objectCV, arguments);
      }
    } catch (Exception e)
    {
      logger.error("[next] Error while loading up/down classes", e);
View Full Code Here

        tagName = listItem.item(i).getNodeName();

        if (tagName.equals("#text") || !listItem.item(i).hasAttributes())
          continue;

        NamedNodeMap attr = listItem.item(i).getAttributes();

        if (attr.getNamedItem("cvtoaa") != null)
        {
          tmpXML = getAAfromCV(objectCV, attr, classCV, tagName);

          if (!tmpXML.trim().equals(""))
            xml += tmpXML;

          continue;
        }

        if (attr.getNamedItem("xml") != null)
        {
          configForQBXML = getDocumentFromString(getDocumentFromString(attr.getNamedItem("xml").getNodeValue()).getElementsByTagName(attr.getNamedItem("tag").getNodeValue()).item(0).toString());

          tmpXML = forwardXML(classCV, attr, objectCV, className, configForQBXML);

          if (!tmpXML.trim().equals(""))
            xml += "<" + tagName + ">" + tmpXML + "</" + tagName + "> \n";

          continue;
        }
        met = attr.getNamedItem("get");
        method = classCV[0].getMethod(met.getNodeValue(), null);
        ret = method.invoke(objectCV, null);

        if (ret != null)
        {
View Full Code Here

        tagName = listItem.item(i).getNodeName();

        if (tagName.equals("#text"))
          continue;

        NamedNodeMap attr = listItem.item(i).getAttributes();

        if (attr.getNamedItem("cvtoaa") != null)
        {
          tmpXML = getAAfromCV(objectCV, attr, classCV, tagName);

          if (!tmpXML.trim().equals(""))
            retxml += tmpXML;

          continue;
        }

        method = classCV[0].getMethod(attr.getNamedItem("get").getNodeValue(), null);

        if (method.invoke(objectCV, null) != null)
        {
          value = method.invoke(objectCV, null).toString();
        } else
View Full Code Here

    String name;
    try
    {
      if (node.hasAttributes())
      {
        NamedNodeMap atts;
        atts = node.getAttributes();

        if (atts.getNamedItem(ATTR_REQUEST_ID) != null)
        {

          return node.getNodeName();
        }
      }
View Full Code Here

            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

    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

    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

  /// @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

TOP

Related Classes of org.w3c.dom.NamedNodeMap

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.