Package org.apache.camel.util.xml
Class XmlLineNumberParser
- java.lang.Object
-
- org.apache.camel.util.xml.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 using
String 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);
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
XmlLineNumberParser.XmlTextTransformer
Allows to plugin a custom text transformer in the parser, that can transform all the text content
-
Field Summary
Fields Modifier and Type Field Description static String
COLUMN_NUMBER
static String
COLUMN_NUMBER_END
static String
LINE_NUMBER
static String
LINE_NUMBER_END
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static Document
parseXml(InputStream is)
Parses the XML.static Document
parseXml(InputStream is, XmlLineNumberParser.XmlTextTransformer xmlTransformer)
Parses the XML.static Document
parseXml(InputStream is, XmlLineNumberParser.XmlTextTransformer xmlTransformer, 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) throws Exception
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, XmlLineNumberParser.XmlTextTransformer xmlTransformer) throws Exception
Parses the XML.- Parameters:
is
- the XML content as an input streamxmlTransformer
- the XML transformer- Returns:
- the DOM model
- Throws:
Exception
- is thrown if error parsing
-
parseXml
public static Document parseXml(InputStream is, XmlLineNumberParser.XmlTextTransformer xmlTransformer, String rootNames, String forceNamespace) throws Exception
Parses the XML.- Parameters:
is
- the XML content as an input streamxmlTransformer
- the XML transformerrootNames
- 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 namespaces to force assign to each node. This may be needed for JAXB unmarshalling from XML -> POJO.- Returns:
- the DOM model
- Throws:
Exception
- is thrown if error parsing
-
-