Package org.w3c.dom

Examples of org.w3c.dom.Attr


            // print element with attributes
         case Node.ELEMENT_NODE: {
               out.print('<');
               out.print(node.getNodeName());
               Attr attrs[] = sortAttributes(node.getAttributes());
               for ( int i = 0; i < attrs.length; i++ ) {
                  Attr attr = attrs[i];
                  out.print(' ');
                  out.print(attr.getNodeName());
                  out.print("=\"");
                  out.print(normalize(attr.getNodeValue()));
                  out.print('"');
               }
               out.print('>');
               NodeList children = node.getChildNodes();
               if ( children != null ) {
View Full Code Here


   /** Returns a sorted list of attributes. */
   protected Attr[] sortAttributes(NamedNodeMap attrs) {

      int len = (attrs != null) ? attrs.getLength() : 0;
      Attr array[] = new Attr[len];
      for ( int i = 0; i < len; i++ ) {
         array[i] = (Attr)attrs.item(i);
      }
      for ( int i = 0; i < len - 1; i++ ) {
         String name  = array[i].getNodeName();
         int    index = i;
         for ( int j = i + 1; j < len; j++ ) {
            String curName = array[j].getNodeName();
            if ( curName.compareTo(name) < 0 ) {
               name  = curName;
               index = j;
            }
         }
         if ( index != i ) {
            Attr temp    = array[i];
            array[i]     = array[index];
            array[index] = temp;
         }
      }

View Full Code Here

            Node n = children.item(i);
            if (n.getNodeType() == Node.ELEMENT_NODE) {
                if (n.getNodeName().equals("config")) {
                    NamedNodeMap atts = n.getAttributes();
                    for (int j=0; j<atts.getLength(); j++) {
                        Attr att = (Attr) atts.item(j);
                        configParams.put(att.getName(), att.getValue());
                    }
                }
                if (n.getNodeName().equals("testcase")) {
                    TestCase tc = createTestCaseFromNode((Element) n);
                    addTest(tc);
View Full Code Here

        }
        NodeList configs = e.getElementsByTagName("config");
        for (int i=0; i<configs.getLength(); i++)  {
            NamedNodeMap atts = configs.item(i).getAttributes();
            for (int j=0; j<atts.getLength(); j++) {
                Attr att = (Attr) atts.item(j);
                result.setConfigParam(att.getName(), att.getValue());
            }
        }
        return result;
    }
View Full Code Here

      // get the constructor params/sig to use
      ConstructorInfo constructor = ConstructorInfo.create(mbeanElement);

      // Check for xmbean specific attributes
      String xmbeandd = null;
      Attr xmbeanddAttr = mbeanElement.getAttributeNode("xmbean-dd");
      if( xmbeanddAttr != null )
         xmbeandd = xmbeanddAttr.getValue();
      String xmbeanCode = mbeanElement.getAttribute("xmbean-code");
      if( xmbeanCode.length() == 0 )
         xmbeanCode = XMBEAN_CODE;

      // Create the mbean instance
      ObjectInstance instance = null;
      try
      {
         if ( xmbeandd == null )
         {
            // Check for the explicit management interface in case of a standard MBean
            Attr itfAttr = mbeanElement.getAttributeNode("interface");
            if (itfAttr != null)
            {
               // Get the good class loader
               ClassLoader classLoader = server.getClassLoader(loaderName);

               // Load interface class
               String itf = itfAttr.getValue();
               Class itfClass = classLoader.loadClass(itf);
               log.debug("About to create bean resource: " + mbeanName + " with code: " + code);
               Object resource = server.instantiate(code,
                                                    loaderName,
                                                    constructor.params,
View Full Code Here

  private static boolean equalElementAttributes(Element e1, Element e2) throws Exception {
    boolean eq = true;
    NamedNodeMap attrs = e1.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      Attr a = (Attr) attrs.item(i);
      if (a.getName().startsWith("xmlns")) {
        // ignore namespace declaration
      }
      // xml:lang has no local name to get
      else if (a.getName().equals("xml:lang")) {
        if (!a.getValue().equals(e2.getAttributeNode(a.getName()).getValue())) {
        checkpoint(eq = false);
        break;
        }
      }
      else if (a.getName().equals("xsi:type")) {
        eq = true;
        break;
      }
      else if (a.getName().equals("xml:base")) {
        eq = true;
        break;
      }
      else if (a.getName().equals("xml:id")) {
        eq = a.getValue().equals(e2.getAttribute("xml:id"));
        break;
      }
      else if (a.getName().indexOf(":") > 0) {
        // qualified
        // ignore schemaLocation hints
        if ((a.getLocalName().equals("schemaLocation")
            || a.getLocalName().equals("noNamespaceSchemaLocation"))
            && a.getNamespaceURI().equals(schema.XSI)) {
          continue;
        }
        if (!equal(a, e2.getAttributeNodeNS(a.getNamespaceURI(), a.getLocalName()))) {
          checkpoint(eq = false);
          break;
        }
      } else if (!equal(a, e2.getAttributeNode(a.getName()))
        && !equal(a, e2.getAttributeNodeNS(a.getNamespaceURI(),a.getName()))) {
        checkpoint(eq = false);
        break;
      }
    }
    return checkpoint(eq);
View Full Code Here

            if (l.getLanguage()!=null) elem.setAttributeNS(XML,"lang",l.getLanguage());
          }
        }
        else if (stmt.getPredicate().getNameSpace().equals(RDF.getURI())) ;
        else {
          Attr a = noSchemaToAttribute(doc,stmt.getPredicate(), ctx);
          elem.setAttributeNode(a);
          noSchemaToXML(a,stmt.getObject(),ctx);
         
        }
      }
View Full Code Here

      pre = ctx.getModel().getNsURIPrefix(ns.substring(0,ns.length()-1));
      if (pre!=null) ns = ns.substring(0,ns.length()-1);
    }
    else pre = ctx.getModel().getNsURIPrefix(ns);
   
    Attr a ;
    if (ns!=null) a = doc.createAttributeNS(ns,name);
    else a = doc.createAttribute(name);
   
    if (pre!=null ) a.setPrefix(pre);
    return a;
  }
View Full Code Here

    // add attributes

    NamedNodeMap attributes = content.getAttributes(this, doc);
    for (int i = 0; i < attributes.getLength(); i++) {
      Attr a = (Attr) attributes.item(i);
      if (!isDefault(a.getName(), a.getValue()))
        e.setAttributeNodeNS(a);
    }
    NodeList l = content.getChildNodes(this, doc);
    for (int i = 0; i < l.getLength(); i++) {
      e.appendChild(l.item(i));
View Full Code Here

      }
    }
    // any matching declarations?
    NamedNodeMap m = e.getAttributes();
    for (int i=0; i<m.getLength(); i++) {
      Attr a = (Attr) m.item(i);
      if (a.getName().startsWith("xmlns:")) {
        String ns = a.getValue();
        if (name.startsWith(ns)) {
          String p = a.getName().substring("xmlns:".length());
          name = name.substring(ns.length());
          if (name.startsWith("#")) name=name.substring(1);
          return p + ":" +name; // in the default namespace
        }
      }
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.