public XmlStreamInfo information() throws IOException {
        if (information.problem != null) {
            return information;
        }

        if (XMLStreamConstants.START_DOCUMENT != reader.getEventType()) {
            information.problem = new IllegalStateException("Expected START_DOCUMENT");
            return information;
        }

        boolean skipComments = false;
        try {
            while (reader.hasNext()) {
                int ev = reader.next();
                switch (ev) {
                    case XMLStreamConstants.COMMENT:
                        if (!skipComments) {
                            // search for modelines
                            String comment = reader.getText();
                            if (comment != null) {
                                comment.lines().map(String::trim).forEach(l -> {
                                    if (l.startsWith("camel-k:")) {
                                        information.modelines.add(l);
                                    }
                                });
                            }
                        }
                        break;
                    case XMLStreamConstants.START_ELEMENT:
                        if (information.rootElementName != null) {
                            // only root element is checked. No need to parse more
                            return information;
                        }
                        skipComments = true;
                        information.rootElementName = reader.getLocalName();
                        information.rootElementNamespace = reader.getNamespaceURI();

                        for (int ns = 0; ns < reader.getNamespaceCount(); ns++) {
                            String prefix = reader.getNamespacePrefix(ns);
                            information.namespaceMapping.put(prefix == null ? "" : prefix, reader.getNamespaceURI(ns));
                        }
                        for (int at = 0; at < reader.getAttributeCount(); at++) {
                            QName qn = reader.getAttributeName(at);
                            String prefix = qn.getPrefix() == null ? "" : qn.getPrefix().trim();
                            String nsURI = qn.getNamespaceURI() == null ? "" : qn.getNamespaceURI().trim();
                            String value = reader.getAttributeValue(at);
                            String localPart = qn.getLocalPart();
                            if (nsURI.isEmpty() || prefix.isEmpty()) {
                                // according to XML spec, this attribut is not namespaced, not in default namespace
                                // https://www.w3.org/TR/xml-names/#defaulting
                                // > The namespace name for an unprefixed attribute name always has no value.
                                information.attributes.put(localPart, value);
                            } else {
                                information.attributes.put("{" + nsURI + "}" + localPart, value);
                                information.attributes.put(prefix + ":" + localPart, value);
                            }
                        }
                        break;
                    case XMLStreamConstants.END_ELEMENT:
                    case XMLStreamConstants.END_DOCUMENT:
                        if (information.rootElementName == null) {
                            information.problem = new IllegalArgumentException("XML Stream is empty");
                            return information;
                        }
                        break;
                    default:
                        break;
                }
            }
        } catch (XMLStreamException e) {
            information.problem = e;
            return information;
        }

        return information;
    }
@Test
    public void simpleRoute() throws IOException {
        String xml = readAllFromFile("simpleRoute.xml");

        XmlStreamDetector detector
                = new XmlStreamDetector(new ByteArrayInputStream(xml.getBytes(StandardCharsets.UTF_8)));
        XmlStreamInfo info = detector.information();
        assertTrue(info.isValid());
        assertEquals("routes", info.getRootElementName());
        assertEquals("http://camel.apache.org/schema/spring", info.getRootElementNamespace());

        assertEquals(2, info.getAttributes().size());
        assertTrue(info.getAttributes().get("xsi:schemaLocation")
                .contains("https://camel.apache.org/schema/spring/camel-spring.xsd"));
        assertTrue(info.getAttributes().get("{http://www.w3.org/2001/XMLSchema-instance}schemaLocation")
                .contains("https://camel.apache.org/schema/spring/camel-spring.xsd"));

        assertEquals(2, info.getNamespaces().size());
        assertEquals("http://camel.apache.org/schema/spring", info.getNamespaces().get(""));
        assertEquals("http://www.w3.org/2001/XMLSchema-instance", info.getNamespaces().get("xsi"));
    }