Package org.apache.camel.xml.io.util
Class XmlStreamDetector
java.lang.Object
org.apache.camel.xml.io.util.XmlStreamDetector
A utility class to determine as quickly as possible (without reading entire stream) important information about an XML document. Most importantly we can collect:
- name and namespace of root element
- root element attributes and values
- prefix:namespace mapping declared at root element
- modeline declarations before root element
While we can have any kind of XML document and the namespaced content may be available at various places in the
document, most sane documents can be examined simply by looking at the root element. This can help e.g.,
with jbang run camel@camel run
to quickly detect what kind of XML document we're trying to run.
This can speed later, full parsing, because we know upfront what's in the doc.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionPerforms the analysis of the XML Stream and returns relevantXML stream information
.
-
Constructor Details
-
XmlStreamDetector
Creates a detector for XML stream. Thestream
should be managed (like try-resources) externally.- Parameters:
xmlStream
- XML to collect information from- Throws:
IOException
- thrown if there is a problem reading the file.
-
-
Method Details
-
information
Performs the analysis of the XML Stream and returns relevantXML stream information
.- Returns:
- Throws:
IOException
-