Esempio n. 1
0
 XmlNode[] getAttributes() {
   NamedNodeMap attrs = this.dom.getAttributes();
   //    TODO    Or could make callers handle null?
   if (attrs == null) throw new IllegalStateException("Must be element.");
   XmlNode[] rv = new XmlNode[attrs.getLength()];
   for (int i = 0; i < attrs.getLength(); i++) {
     rv[i] = createImpl(attrs.item(i));
   }
   return rv;
 }
 /** @param element */
 private void validatePlugins(Element parent) {
   NodeList list = getChildrenByName(parent, "plugin"); // $NON-NLS-1$
   for (int i = 0; i < list.getLength(); i++) {
     if (fMonitor.isCanceled()) return;
     Element plugin = (Element) list.item(i);
     assertAttributeDefined(plugin, "id", CompilerFlags.ERROR); // $NON-NLS-1$
     assertAttributeDefined(plugin, "version", CompilerFlags.ERROR); // $NON-NLS-1$
     NamedNodeMap attributes = plugin.getAttributes();
     boolean isFragment =
         plugin.getAttribute("fragment").equals("true"); // $NON-NLS-1$ //$NON-NLS-2$
     for (int j = 0; j < attributes.getLength(); j++) {
       Attr attr = (Attr) attributes.item(j);
       String name = attr.getName();
       if (name.equals("id")) { // $NON-NLS-1$
         validatePluginID(plugin, attr, isFragment);
       } else if (name.equals("version")) { // $NON-NLS-1$
         validateVersionAttribute(plugin, attr);
         validateVersion(plugin, attr);
       } else if (name.equals("fragment") || name.equals("unpack")) { // $NON-NLS-1$ //$NON-NLS-2$
         validateBoolean(plugin, attr);
       } else if (!name.equals("os")
           && !name.equals("ws")
           && !name.equals("nl") // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
           && !name.equals("arch")
           && !name.equals("download-size") // $NON-NLS-1$ //$NON-NLS-2$
           && !name.equals("install-size")
           && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$
         reportUnknownAttribute(plugin, name, CompilerFlags.ERROR);
       }
     }
     validateUnpack(plugin);
   }
 }
Esempio n. 3
0
  private void gatherNamespaces(Element element, List<URI> namespaceSources) throws SAXException {
    NamedNodeMap attributes = element.getAttributes();
    int attributeCount = attributes.getLength();

    for (int i = 0; i < attributeCount; i++) {
      Attr attribute = (Attr) attributes.item(i);
      String namespace = attribute.getNamespaceURI();

      if (XMLConstants.XMLNS_ATTRIBUTE_NS_URI.equals(namespace)) {
        try {
          namespaceSources.add(new URI(attribute.getValue()));
        } catch (URISyntaxException e) {
          throw new SAXException(
              "Cannot validate this document with this class.  Namespaces must be valid URIs.  Found Namespace: '"
                  + attribute.getValue()
                  + "'.",
              e);
        }
      }
    }

    NodeList childNodes = element.getChildNodes();
    int childCount = childNodes.getLength();
    for (int i = 0; i < childCount; i++) {
      Node child = childNodes.item(i);

      if (child.getNodeType() == Node.ELEMENT_NODE) {
        gatherNamespaces((Element) child, namespaceSources);
      }
    }
  }
Esempio n. 4
0
  /** 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;
      }
    }

    return (array);
  } // sortAttributes(NamedNodeMap):Attr[]
Esempio n. 5
0
  void removeNamespace(Namespace namespace) {
    Namespace current = getNodeNamespace();

    //    Do not remove in-use namespace
    if (namespace.is(current)) return;
    NamedNodeMap attrs = this.dom.getAttributes();
    for (int i = 0; i < attrs.getLength(); i++) {
      XmlNode attr = XmlNode.createImpl(attrs.item(i));
      if (namespace.is(attr.getNodeNamespace())) return;
    }

    //    TODO    I must confess I am not sure I understand the spec fully.  See ECMA357 13.4.4.31
    String existingPrefix = getExistingPrefixFor(namespace);
    if (existingPrefix != null) {
      if (namespace.isUnspecifiedPrefix()) {
        //    we should remove any namespace with this URI from scope; we do this by declaring a
        // namespace with the same
        //    prefix as the existing prefix and setting its URI to the default namespace
        declareNamespace(existingPrefix, getDefaultNamespace().getUri());
      } else {
        if (existingPrefix.equals(namespace.getPrefix())) {
          declareNamespace(existingPrefix, getDefaultNamespace().getUri());
        }
      }
    } else {
      //    the argument namespace is not declared in this scope, so do nothing.
    }
  }
Esempio n. 6
0
 /**
  * Get a list of the names for all of the attributes for this node.
  *
  * @webref xml:method
  * @brief Returns a list of names of all attributes as an array
  */
 public String[] listAttributes() {
   NamedNodeMap nnm = node.getAttributes();
   String[] outgoing = new String[nnm.getLength()];
   for (int i = 0; i < outgoing.length; i++) {
     outgoing[i] = nnm.item(i).getNodeName();
   }
   return outgoing;
 }
 private void validateImports(Element parent) {
   NodeList list = getChildrenByName(parent, "import"); // $NON-NLS-1$
   for (int i = 0; i < list.getLength(); i++) {
     if (fMonitor.isCanceled()) return;
     Element element = (Element) list.item(i);
     Attr plugin = element.getAttributeNode("plugin"); // $NON-NLS-1$
     Attr feature = element.getAttributeNode("feature"); // $NON-NLS-1$
     if (plugin == null && feature == null) {
       assertAttributeDefined(element, "plugin", CompilerFlags.ERROR); // $NON-NLS-1$
     } else if (plugin != null && feature != null) {
       reportExclusiveAttributes(
           element, "plugin", "feature", CompilerFlags.ERROR); // $NON-NLS-1$//$NON-NLS-2$
     } else if (plugin != null) {
       validatePluginID(element, plugin, false);
     } else if (feature != null) {
       validateFeatureID(element, feature);
     }
     NamedNodeMap attributes = element.getAttributes();
     for (int j = 0; j < attributes.getLength(); j++) {
       Attr attr = (Attr) attributes.item(j);
       String name = attr.getName();
       if (name.equals("version")) { // $NON-NLS-1$
         validateVersionAttribute(element, attr);
       } else if (name.equals("match")) { // $NON-NLS-1$
         if (element.getAttributeNode("patch") != null) { // $NON-NLS-1$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchedMatch, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else {
           validateMatch(element, attr);
         }
       } else if (name.equals("patch")) { // $NON-NLS-1$
         if ("true".equalsIgnoreCase(attr.getValue()) && feature == null) { // $NON-NLS-1$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchPlugin, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else if ("true".equalsIgnoreCase(attr.getValue())
             && element.getAttributeNode("version") == null) { // $NON-NLS-1$ //$NON-NLS-2$
           report(
               NLS.bind(PDECoreMessages.Builders_Feature_patchedVersion, attr.getValue()),
               getLine(element, attr.getValue()),
               CompilerFlags.ERROR,
               PDEMarkerFactory.CAT_FATAL);
         } else {
           validateBoolean(element, attr);
         }
       } else if (!name.equals("plugin")
           && !name.equals("feature")
           && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
         reportUnknownAttribute(element, name, CompilerFlags.ERROR);
       }
     }
   }
 }
 public String getAtributo(Node nodo, String nombreAtributo) {
   NamedNodeMap atts;
   atts = nodo.getAttributes();
   if (atts == null) return null;
   for (int i = 0; i < atts.getLength(); i++) {
     Node atributo = atts.item(i);
     if (atributo.getNodeName().equalsIgnoreCase(nombreAtributo)) return atributo.getNodeValue();
   }
   return null;
 }
  /**
   * Counts the attributenode for an element (xmlns attributes ignored)
   *
   * @param attributesR attributesMap
   * @return number of attributes
   */
  private int countAttributes(NamedNodeMap attributesR) {
    int cntAttributes = 0;

    for (int i = 0; i < attributesR.getLength(); i++) {
      if (!attributesR.item(i).getNodeName().startsWith(XMLConstants.XMLNS_ATTRIBUTE)) {
        cntAttributes++;
      }
    }

    return cntAttributes;
  }
Esempio n. 10
0
 protected Element copyElementToName(Element element, String tagName) {
   Element newElement = element.getOwnerDocument().createElement(tagName);
   NamedNodeMap attrs = element.getAttributes();
   for (int i = 0; i < attrs.getLength(); i++) {
     Node attribute = attrs.item(i);
     newElement.setAttribute(attribute.getNodeName(), attribute.getNodeValue());
   }
   for (int i = 0; i < element.getChildNodes().getLength(); i++) {
     newElement.appendChild(element.getChildNodes().item(i).cloneNode(true));
   }
   return newElement;
 }
Esempio n. 11
0
  public static Map<String, String> getAttrList(Node node) {
    Map<String, String> map = new HashMap<String, String>();

    NamedNodeMap list = node.getAttributes();
    if (list != null)
      for (int i = 0; i < list.getLength(); i++) {
        Attr attr = (Attr) list.item(i);
        map.put(attr.getName(), attr.getValue());
      }

    return map;
  }
Esempio n. 12
0
 private Properties parseAttributes(Node n) {
   Properties attributes = new Properties();
   NamedNodeMap attributeNodes = n.getAttributes();
   if (attributeNodes != null) {
     for (int i = 0; i < attributeNodes.getLength(); i++) {
       Node attribute = attributeNodes.item(i);
       String value = attribute.getNodeValue();
       attributes.put(attribute.getNodeName(), value);
     }
   }
   return attributes;
 }
 /**
  * Runs the test case.
  *
  * @throws Throwable Any uncaught exception causes test to fail
  */
 public void runTest() throws Throwable {
   Document doc;
   NodeList elementList;
   Node testEmployee;
   NamedNodeMap attributes;
   int length;
   doc = (Document) load("staff", true);
   elementList = doc.getElementsByTagName("address");
   testEmployee = elementList.item(2);
   attributes = testEmployee.getAttributes();
   length = (int) attributes.getLength();
   assertEquals("length", 2, length);
 }
Esempio n. 14
0
 // dump and element
 public void dump(Element e) throws Exception {
   System.out.println("Element " + e.getNodeName());
   NamedNodeMap attrs = e.getAttributes();
   for (int i = 0; i < attrs.getLength(); i++) {
     Attr attr = (Attr) attrs.item(i);
     System.out.println("  " + attr.getName() + "=" + attr.getValue());
   }
   NodeList nodes = e.getChildNodes();
   for (int i = 0; i < nodes.getLength(); i++) {
     Node node = nodes.item(i);
     if (node instanceof Element) dump((Element) node);
   }
 }
 private void validateInstallHandler(Element element) {
   NodeList elements = getChildrenByName(element, "install-handler"); // $NON-NLS-1$
   if (elements.getLength() > 0) {
     if (fMonitor.isCanceled()) return;
     Element handler = (Element) elements.item(0);
     NamedNodeMap attributes = handler.getAttributes();
     for (int i = 0; i < attributes.getLength(); i++) {
       String name = attributes.item(i).getNodeName();
       if (!name.equals("library") && !name.equals("handler")) // $NON-NLS-1$ //$NON-NLS-2$
       reportUnknownAttribute(handler, name, CompilerFlags.ERROR);
     }
     reportExtraneousElements(elements, 1);
   }
 }
Esempio n. 16
0
 void invalidateNamespacePrefix() {
   if (!(dom instanceof Element)) throw new IllegalStateException();
   String prefix = this.dom.getPrefix();
   QName after = QName.create(this.dom.getNamespaceURI(), this.dom.getLocalName(), null);
   renameNode(after);
   NamedNodeMap attrs = this.dom.getAttributes();
   for (int i = 0; i < attrs.getLength(); i++) {
     if (attrs.item(i).getPrefix().equals(prefix)) {
       createImpl(attrs.item(i))
           .renameNode(
               QName.create(attrs.item(i).getNamespaceURI(), attrs.item(i).getLocalName(), null));
     }
   }
 }
Esempio n. 17
0
  /**
   * Get the default namespace associated with the supplied element.
   *
   * @param element The element to be checked.
   * @return The default namespace, or null if none was found.
   */
  public static String getDefaultNamespace(Element element) {
    NamedNodeMap attributes = element.getAttributes();
    int attributeCount = attributes.getLength();

    for (int i = 0; i < attributeCount; i++) {
      Attr attribute = (Attr) attributes.item(i);

      if (XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getName())
          && XMLConstants.XMLNS_ATTRIBUTE.equals(attribute.getLocalName())) {
        return attribute.getValue();
      }
    }

    return null;
  }
Esempio n. 18
0
  public static void dumpElement(Element element, String indent) {
    System.out.println(indent + "Element: " + element.getNodeName());
    NamedNodeMap attributes = element.getAttributes();

    if ((attributes != null) && (attributes.getLength() > 0)) {
      System.out.println(indent + "Attributes:");
      for (int i = 0; i < attributes.getLength(); i++) {
        Node attr = attributes.item(i);
        System.out.println(indent + "  " + attr.getNodeName() + "=" + attr.getNodeValue());
      }
    }

    NodeList children = element.getChildNodes();

    for (int i = 0; i < children.getLength(); i++) {
      Node n = children.item(i);

      if (n instanceof Element) {
        dumpElement((Element) n, indent + "    ");
      } else if (n instanceof CharacterData) {
        System.out.println(indent + "    " + ((CharacterData) n).getData());
      }
    }
  }
  public void validateContent(IProgressMonitor monitor) {
    Element element = getDocumentRoot();
    if (element == null) return;
    String elementName = element.getNodeName();
    if (!"plugin".equals(elementName)
        && !"fragment".equals(elementName)) { // $NON-NLS-1$ //$NON-NLS-2$
      reportIllegalElement(element, CompilerFlags.ERROR);
    } else {
      int severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED);
      if (severity != CompilerFlags.IGNORE) {
        NamedNodeMap attrs = element.getAttributes();
        for (int i = 0; i < attrs.getLength(); i++) {
          reportUnusedAttribute(element, attrs.item(i).getNodeName(), severity);
        }
      }

      NodeList children = element.getChildNodes();
      for (int i = 0; i < children.getLength(); i++) {
        if (monitor.isCanceled()) break;
        Element child = (Element) children.item(i);
        String name = child.getNodeName();
        if (name.equals("extension")) { // $NON-NLS-1$
          validateExtension(child);
        } else if (name.equals("extension-point")) { // $NON-NLS-1$
          validateExtensionPoint(child);
        } else {
          if (!name.equals("runtime") && !name.equals("requires")) { // $NON-NLS-1$ //$NON-NLS-2$
            severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ELEMENT);
            if (severity != CompilerFlags.IGNORE) reportIllegalElement(child, severity);
          } else {
            severity = CompilerFlags.getFlag(fProject, CompilerFlags.P_DEPRECATED);
            if (severity != CompilerFlags.IGNORE) reportUnusedElement(child, severity);
          }
        }
      }

      IExtensions extensions = fModel.getExtensions();
      if (extensions != null
          && extensions.getExtensions().length == 0
          && extensions.getExtensionPoints().length == 0)
        report(
            MDECoreMessages.Builders_Manifest_useless_file,
            -1,
            IMarker.SEVERITY_WARNING,
            MDEMarkerFactory.P_USELESS_FILE,
            MDEMarkerFactory.CAT_OTHER);
    }
  }
Esempio n. 20
0
  /**
   * Prints a XML node.
   *
   * @param out The PrintStream where to print the node.
   * @param prefix The prefix to put before every line.
   * @param node The node to print.
   * @throws IOException If printing failed.
   */
  private static void printNode(PrintStream out, String prefix, Node node) throws IOException {
    prefix = "";

    String name = node.getNodeName();

    boolean isText = name.equals("#text");
    boolean isComment = name.equals("#comment");
    boolean isCDATA = name.equals("#cdata-section");
    if (isText) {
      // This is a text tag
      String text = node.getNodeValue();
      text = RegainToolkit.replace(text, "<", "&lt;");
      text = RegainToolkit.replace(text, ">", "&gt;");
      text = RegainToolkit.replace(text, "--", "&minus;&minus;");
      out.print(text);
    } else if (isComment) {
      // This is a comment tag
      String comment = node.getNodeValue();
      out.print("<!--" + comment + "-->");
    } else if (isCDATA) {
      String text = node.getNodeValue();
      out.print("<![CDATA[" + text + "]]>");
    } else {
      // This is a normal tag
      out.print(prefix + "<" + name);
      if (node.hasAttributes()) {
        NamedNodeMap attributes = node.getAttributes();
        for (int i = 0; i < attributes.getLength(); i++) {
          Node attrib = attributes.item(i);
          out.print(" " + attrib.getNodeName() + "=\"" + attrib.getNodeValue() + "\"");
        }
      }

      if (!node.hasChildNodes()) {
        out.print("/>");
      } else {
        out.print(">");
        NodeList childList = node.getChildNodes();
        String childPrefix = prefix + "  ";
        for (int i = 0; i < childList.getLength(); i++) {
          printNode(out, childPrefix, childList.item(i));
        }
        out.print(prefix + "</" + name + ">");
      }
    }
  }
Esempio n. 21
0
  protected static XmlConfigurator parse(Element root_element) throws java.io.IOException {
    XmlConfigurator configurator = null;
    final LinkedList<ProtocolConfiguration> prot_data = new LinkedList<ProtocolConfiguration>();

    /**
     * CAUTION: crappy code ahead ! I (bela) am not an XML expert, so the code below is pretty
     * amateurish... But it seems to work, and it is executed only on startup, so no perf loss on
     * the critical path. If somebody wants to improve this, please be my guest.
     */
    try {
      String root_name = root_element.getNodeName();
      if (!"config".equals(root_name.trim().toLowerCase()))
        throw new IOException("the configuration does not start with a <config> element");

      NodeList prots = root_element.getChildNodes();
      for (int i = 0; i < prots.getLength(); i++) {
        Node node = prots.item(i);
        if (node.getNodeType() != Node.ELEMENT_NODE) continue;

        Element tag = (Element) node;
        String protocol = tag.getTagName();
        Map<String, String> params = new HashMap<String, String>();

        NamedNodeMap attrs = tag.getAttributes();
        int attrLength = attrs.getLength();
        for (int a = 0; a < attrLength; a++) {
          Attr attr = (Attr) attrs.item(a);
          String name = attr.getName();
          String value = attr.getValue();
          params.put(name, value);
        }
        ProtocolConfiguration cfg = new ProtocolConfiguration(protocol, params);
        prot_data.add(cfg);
      }
      configurator = new XmlConfigurator(prot_data);
    } catch (Exception x) {
      if (x instanceof java.io.IOException) throw (java.io.IOException) x;
      else {
        IOException tmp = new IOException();
        tmp.initCause(x);
        throw tmp;
      }
    }
    return configurator;
  }
  // DOM input
  public void declareNamespace(Element element) {
    NamedNodeMap attrs = element.getAttributes();
    int size = attrs.getLength();

    for (int i = 0; i < size; i++) {
      Attr attr = (Attr) attrs.item(i);
      String qName = attr.getName();

      if (qName.startsWith("xmlns:")) {
        String uri = attr.getValue();
        String prefix = qName.substring("xmlns:".length());
        declareNamespace(prefix, uri);
      } else if (qName.startsWith("xmlns")) {
        String uri = attr.getValue();
        declareNamespace("", uri);
      }
    }
  }
 private void validateUpdateURL(Element parent) {
   NodeList list = getChildrenByName(parent, "update"); // $NON-NLS-1$
   if (list.getLength() > 0) {
     if (fMonitor.isCanceled()) return;
     Element update = (Element) list.item(0);
     assertAttributeDefined(update, "url", CompilerFlags.ERROR); // $NON-NLS-1$
     NamedNodeMap attributes = update.getAttributes();
     for (int i = 0; i < attributes.getLength(); i++) {
       String name = attributes.item(i).getNodeName();
       if (name.equals("url")) { // $NON-NLS-1$
         validateURL(update, "url"); // $NON-NLS-1$
       } else if (!name.equals("label")) { // $NON-NLS-1$
         reportUnknownAttribute(update, name, CompilerFlags.ERROR);
       }
     }
     reportExtraneousElements(list, 1);
   }
 }
Esempio n. 24
0
 private void addNamespaces(Namespaces rv, Element element) {
   if (element == null) throw new RuntimeException("element must not be null");
   String myDefaultNamespace = toUri(element.lookupNamespaceURI(null));
   String parentDefaultNamespace = "";
   if (element.getParentNode() != null) {
     parentDefaultNamespace = toUri(element.getParentNode().lookupNamespaceURI(null));
   }
   if (!myDefaultNamespace.equals(parentDefaultNamespace)
       || !(element.getParentNode() instanceof Element)) {
     rv.declare(Namespace.create("", myDefaultNamespace));
   }
   NamedNodeMap attributes = element.getAttributes();
   for (int i = 0; i < attributes.getLength(); i++) {
     Attr attr = (Attr) attributes.item(i);
     if (attr.getPrefix() != null && attr.getPrefix().equals("xmlns")) {
       rv.declare(Namespace.create(attr.getLocalName(), attr.getValue()));
     }
   }
 }
 private void validateExistingExtensionAttributes(
     Element element, NamedNodeMap attrs, ISchemaElement schemaElement) {
   for (int i = 0; i < attrs.getLength(); i++) {
     Attr attr = (Attr) attrs.item(i);
     ISchemaAttribute attInfo = schemaElement.getAttribute(attr.getName());
     if (attInfo == null) {
       HashSet allowedElements = new HashSet();
       computeAllowedElements(schemaElement.getType(), allowedElements);
       if (allowedElements.contains(attr.getName())) {
         validateJavaAttribute(element, attr);
       } else {
         int flag = CompilerFlags.getFlag(fProject, CompilerFlags.P_UNKNOWN_ATTRIBUTE);
         if (flag != CompilerFlags.IGNORE) reportUnknownAttribute(element, attr.getName(), flag);
       }
     } else {
       validateExtensionAttribute(element, attr, attInfo);
     }
   }
 }
Esempio n. 26
0
  @Test
  public void testgetAttributesWithNamedNodeMap() throws Exception {
    //		builderFactory = DocumentBuilderFactory.newInstance();
    builderFactory.setNamespaceAware(true);

    File f = new File(System.getProperty("user.dir"), "src/test/resources/sample-springbeans.xml");
    DocumentBuilder builder = builderFactory.newDocumentBuilder();
    Document doc = builder.parse(f);
    Element root = doc.getDocumentElement();
    //		System.out.println("* current impl:  " + doc.getClass().getName());

    // id, class
    Map<String, String> actualMap = new HashMap<String, String>();

    NodeList list = root.getChildNodes();
    for (int i = 0; i < list.getLength(); i++) {
      Node node = list.item(i);
      if (node instanceof Element) {
        Element elem = (Element) node;
        if (elem.getTagName().equals("beans:bean")) {
          //					System.out.println("bean[" + elem.getAttribute("id") + "]");
          NamedNodeMap map = elem.getAttributes();
          String valueId = null;
          String valueClass = null;
          for (int x = 0; x < map.getLength(); x++) {
            Node attr = map.item(x);
            if (attr.getNodeName().equals("id")) valueId = attr.getNodeValue();
            if (attr.getNodeName().equals("class")) valueClass = attr.getNodeValue();
          }
          if (valueId != null && valueClass != null) actualMap.put(valueId, valueClass);
        }
      }
    }

    Map<String, String> expected = new HashMap<String, String>();
    expected.put("authenticationManager", "org.springframework.security.providers.ProviderManager");
    expected.put(
        "daoAuthenticationProvider",
        "org.springframework.security.providers.dao.DaoAuthenticationProvider");
    expected.put(
        "loggerListener", "org.springframework.security.event.authentication.LoggerListener");
    Assert.assertEquals("Attributes with NamedNodeMap", expected, actualMap);
  }
 private void validateDescription(Element parent) {
   NodeList list = getChildrenByName(parent, "description"); // $NON-NLS-1$
   if (list.getLength() > 0) {
     if (fMonitor.isCanceled()) return;
     Element element = (Element) list.item(0);
     validateElementWithContent((Element) list.item(0), true);
     NamedNodeMap attributes = element.getAttributes();
     for (int i = 0; i < attributes.getLength(); i++) {
       Attr attr = (Attr) attributes.item(i);
       String name = attr.getName();
       if (name.equals("url")) { // $NON-NLS-1$
         validateURL(element, name);
       } else {
         reportUnknownAttribute(element, name, CompilerFlags.ERROR);
       }
     }
     reportExtraneousElements(list, 1);
   }
 }
 @Override
 protected AbstractBeanDefinition parseInternal(Element element, ParserContext parserContext) {
   BeanDefinitionBuilder builder =
       BeanDefinitionBuilder.genericBeanDefinition(SpringJolokiaConfigHolder.class);
   Map<String, String> config = new HashMap<String, String>();
   NamedNodeMap attrs = element.getAttributes();
   for (int i = 0; i < attrs.getLength(); i++) {
     Attr attr = (Attr) attrs.item(i);
     String name = attr.getName();
     if (skipMap.contains(name)) {
       continue;
     }
     config.put(name, attr.getValue());
   }
   builder.addPropertyValue("config", config);
   String order = element.getAttribute("order");
   if (StringUtils.hasText(order)) {
     builder.addPropertyValue("order", Integer.parseInt(order));
   }
   return builder.getBeanDefinition();
 }
 /**
  * @param node
  * @param indent
  */
 public static String toString(Node node, int indent) {
   StringBuffer str = new StringBuffer();
   for (int i = 0; i < indent; ++i) str.append("    ");
   str.append(node);
   if (node.hasAttributes()) {
     NamedNodeMap attrs = node.getAttributes();
     for (int j = 0; j < attrs.getLength(); ++j) {
       Node attr = attrs.item(j);
       // str.append(toString(attr,indent+2));
       str.append(" ");
       str.append(attr);
     }
   }
   str.append("\n");
   ++indent;
   for (Node child = node.getFirstChild(); child != null; child = child.getNextSibling()) {
     str.append(toString(child, indent));
     // str.append("\n");
   }
   return str.toString();
 }
  private void validateIncludes(Element parent) {
    NodeList list = getChildrenByName(parent, "includes"); // $NON-NLS-1$
    for (int i = 0; i < list.getLength(); i++) {
      if (fMonitor.isCanceled()) return;
      Element include = (Element) list.item(i);
      if (assertAttributeDefined(include, "id", CompilerFlags.ERROR) // $NON-NLS-1$
          && assertAttributeDefined(
              include,
              "version", //$NON-NLS-1$
              CompilerFlags.ERROR)) {

        validateFeatureID(include, include.getAttributeNode("id")); // $NON-NLS-1$
      }
      NamedNodeMap attributes = include.getAttributes();
      for (int j = 0; j < attributes.getLength(); j++) {
        Attr attr = (Attr) attributes.item(j);
        String name = attr.getName();
        if (name.equals("version")) { // $NON-NLS-1$
          validateVersionAttribute(include, attr);
        } else if (name.equals("optional")) { // $NON-NLS-1$
          validateBoolean(include, attr);
        } else if (name.equals("search-location")) { // $NON-NLS-1$
          String value = include.getAttribute("search-location"); // $NON-NLS-1$
          if (!value.equals("root")
              && !value.equals("self")
              && !value.equals("both")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
            reportIllegalAttributeValue(include, attr);
          }
        } else if (!name.equals("id")
            && !name.equals("name")
            && !name.equals("os")
            && !name.equals("ws") // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$ //$NON-NLS-4$
            && !name.equals("nl")
            && !name.equals("arch")
            && !name.equals("filter")) { // $NON-NLS-1$ //$NON-NLS-2$ //$NON-NLS-3$
          reportUnknownAttribute(include, name, CompilerFlags.ERROR);
        }
      }
    }
  }