Package org.apache.camel.parser.helper
Class XmlLineNumberParser
- java.lang.Object
-
- org.apache.camel.parser.helper.XmlLineNumberParser
-
public final class XmlLineNumberParser extends Object
An XML parser that uses SAX to include line and column number for each XML element in the parsed Document. The line number and column number can be obtained from a Node/Element usingString lineNumber = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER); String lineNumberEnd = (String) node.getUserData(XmlLineNumberParser.LINE_NUMBER_END); String columnNumber = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER); String columnNumberEnd = (String) node.getUserData(XmlLineNumberParser.COLUMN_NUMBER_END);
Mind that start and end numbers are the same for single-level XML tags.
-
-
Field Summary
Fields Modifier and Type Field Description static StringCOLUMN_NUMBERstatic StringCOLUMN_NUMBER_ENDstatic StringLINE_NUMBERstatic StringLINE_NUMBER_END
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static DocumentparseXml(InputStream is)Parses the XML.static DocumentparseXml(InputStream is, String rootNames, String forceNamespace)Parses the XML.
-
-
-
Field Detail
-
LINE_NUMBER
public static final String LINE_NUMBER
- See Also:
- Constant Field Values
-
COLUMN_NUMBER
public static final String COLUMN_NUMBER
- See Also:
- Constant Field Values
-
LINE_NUMBER_END
public static final String LINE_NUMBER_END
- See Also:
- Constant Field Values
-
COLUMN_NUMBER_END
public static final String COLUMN_NUMBER_END
- See Also:
- Constant Field Values
-
-
Method Detail
-
parseXml
public static Document parseXml(InputStream is)
Parses the XML.- Parameters:
is- the XML content as an input stream- Returns:
- the DOM model
- Throws:
Exception- is thrown if error parsing
-
parseXml
public static Document parseXml(InputStream is, String rootNames, String forceNamespace)
Parses the XML.- Parameters:
is- the XML content as an input streamrootNames- one or more root names that is used as baseline for beginning the parsing, for example camelContext to start parsing when Camel is discovered. Multiple names can be defined separated by commaforceNamespace- an optional namespace to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.- Returns:
- the DOM model
- Throws:
org.apache.camel.RuntimeCamelException- is thrown if error parsing (wraps the underlying exception)
-
-