Package org.apache.camel.util.xml
Class XmlLineNumberParser
java.lang.Object
org.apache.camel.util.xml.XmlLineNumberParser
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
Modifier and TypeClassDescriptionstatic interface
Allows to plugin a custom text transformer in the parser, that can transform all the text content -
Field Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic 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 Details
-
LINE_NUMBER
- See Also:
-
COLUMN_NUMBER
- See Also:
-
LINE_NUMBER_END
- See Also:
-
COLUMN_NUMBER_END
- See Also:
-
-
Method Details
-
parseXml
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
-