Package org.apache.camel.converter.jaxp
Class XmlConverter
- java.lang.Object
-
- org.apache.camel.converter.jaxp.XmlConverter
-
@Converter(generateLoader=true) public class XmlConverter extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static StringdefaultCharsetstatic StringDOCUMENT_BUILDER_FACTORY_FEATUREstatic StringOUTPUT_PROPERTIES_PREFIX
-
Constructor Summary
Constructors Constructor Description XmlConverter()XmlConverter(DocumentBuilderFactory documentBuilderFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconfigureSaxonTransformerFactory(TransformerFactory factory)Make a Saxon TransformerFactory more JAXP compliant by configuring it to send <xsl:message> output to the ErrorListener.DocumentcreateDocument()DocumentBuildercreateDocumentBuilder()DocumentBuildercreateDocumentBuilder(DocumentBuilderFactory factory)DocumentBuilderFactorycreateDocumentBuilderFactory()SAXParserFactorycreateSAXParserFactory()TransformercreateTransformer()TransformerFactorycreateTransformerFactory()PropertiesdefaultOutputProperties()Returns the default set of output properties for conversions.DocumentBuilderFactorygetDocumentBuilderFactory()DocumentBuilderFactorygetDocumentBuilderFactory(org.apache.camel.Exchange exchange)TransformerFactorygetTransformerFactory()voidsetDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)voidsetTransformerFactory(TransformerFactory transformerFactory)protected voidsetupFeatures(DocumentBuilderFactory factory)BooleantoBoolean(NodeList list)Converts the given NodeList to a booleanbyte[]toByteArray(Source source, org.apache.camel.Exchange exchange)Converts the given input Source into bytesBytesSourcetoBytesSource(byte[] data)Converts the given byte[] to a SourceDocumenttoDOMDocument(byte[] data, org.apache.camel.Exchange exchange)Converts the given data to a DOM documentDocumenttoDOMDocument(File file, org.apache.camel.Exchange exchange)Converts the givenFileto a DOM documentDocumenttoDOMDocument(InputStream in, org.apache.camel.Exchange exchange)Converts the givenInputStreamto a DOM documentDocumenttoDOMDocument(Reader in, org.apache.camel.Exchange exchange)Converts the givenReaderto a DOM documentDocumenttoDOMDocument(String text, org.apache.camel.Exchange exchange)Converts the givenStringto a DOM documentDocumenttoDOMDocument(Source source)Create a DOM document from the given source.DocumenttoDOMDocument(Node node)Create a DOM document from the given Node.DocumenttoDOMDocument(InputSource in, org.apache.camel.Exchange exchange)Converts the givenInputSourceto a DOM documentDocumenttoDOMDocumentFromSingleNodeList(NodeList nl)Convert a NodeList consisting of just 1 node to a DOM Document.ElementtoDOMElement(Source source)Create a DOM element from the given source.ElementtoDOMElement(Node node)Create a DOM element from the DOM node.NodetoDOMNode(Source source)Converts the given TRaX Source into a W3C DOM nodeNodetoDOMNodeFromSAX(SAXSource source)NodetoDOMNodeFromSingleNodeList(NodeList nl)Convert a NodeList consisting of just 1 node to a DOM Node.NodetoDOMNodeFromStAX(StAXSource source)DOMSourcetoDOMSource(byte[] bytes)Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).DOMSourcetoDOMSource(File file, org.apache.camel.Exchange exchange)DOMSourcetoDOMSource(InputStream is, org.apache.camel.Exchange exchange)DOMSourcetoDOMSource(String text)Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).DOMSourcetoDOMSource(Source source, org.apache.camel.Exchange exchange)Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).DOMSourcetoDOMSource(Document document)Converts the given Document to a DOMSourceDOMSourcetoDOMSource(Node node)Converts the given Node to a SourceDOMSourcetoDOMSourceFromSAX(SAXSource source)DOMSourcetoDOMSourceFromStAX(StAXSource source)DOMSourcetoDOMSourceFromStream(StreamSource source, org.apache.camel.Exchange exchange)InputSourcetoInputSource(File file, org.apache.camel.Exchange exchange)InputSourcetoInputSource(InputStream is, org.apache.camel.Exchange exchange)InputStreamtoInputStream(DOMSource source, org.apache.camel.Exchange exchange)InputStreamtoInputStream(Document dom, org.apache.camel.Exchange exchange)QNametoQName(String str)Converts the given string to a QName.ReadertoReaderFromSource(Source src, org.apache.camel.Exchange exchange)voidtoResult(Source source, Result result)Converts the given input Source into the required resultvoidtoResult(Source source, Result result, Properties outputProperties)Converts the given input Source into the required resultSAXSourcetoSAXSource(byte[] in, org.apache.camel.Exchange exchange)Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).SAXSourcetoSAXSource(File file, org.apache.camel.Exchange exchange)Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).SAXSourcetoSAXSource(InputStream source, org.apache.camel.Exchange exchange)Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).SAXSourcetoSAXSource(String source, org.apache.camel.Exchange exchange)Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).SAXSourcetoSAXSource(Source source, org.apache.camel.Exchange exchange)Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).SAXSourcetoSAXSourceFromDOM(DOMSource source, org.apache.camel.Exchange exchange)SAXSourcetoSAXSourceFromStAX(StAXSource source, org.apache.camel.Exchange exchange)SAXSourcetoSAXSourceFromStream(StreamSource source, org.apache.camel.Exchange exchange)SourcetoSource(String data)Converts the given String to a SourceStAXSourcetoStAXSource(byte[] in, org.apache.camel.Exchange exchange)Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).StAXSourcetoStAXSource(File file, org.apache.camel.Exchange exchange)Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).StAXSourcetoStAXSource(InputStream source, org.apache.camel.Exchange exchange)Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).StAXSourcetoStAXSource(String source, org.apache.camel.Exchange exchange)Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).StreamSourcetoStreamSource(byte[] in, org.apache.camel.Exchange exchange)StreamSourcetoStreamSource(File in)StreamSourcetoStreamSource(InputStream in)StreamSourcetoStreamSource(Reader in)StreamSourcetoStreamSource(ByteBuffer in, org.apache.camel.Exchange exchange)StreamSourcetoStreamSource(Source source, org.apache.camel.Exchange exchange)StreamSourcetoStreamSourceFromDOM(DOMSource source, org.apache.camel.Exchange exchange)StreamSourcetoStreamSourceFromSAX(SAXSource source, org.apache.camel.Exchange exchange)StreamSourcetoStreamSourceFromStAX(StAXSource source, org.apache.camel.Exchange exchange)StringtoString(Source source, org.apache.camel.Exchange exchange)Converts the given input Source into textStringtoString(Node node, org.apache.camel.Exchange exchange)Converts the given input Node into textStringtoStringFromDocument(Document document, Properties outputOptions)Converts the given Document to into textStringSourcetoStringSource(String data)Converts the given String to a Source
-
-
-
Field Detail
-
OUTPUT_PROPERTIES_PREFIX
public static final String OUTPUT_PROPERTIES_PREFIX
- See Also:
- Constant Field Values
-
DOCUMENT_BUILDER_FACTORY_FEATURE
public static final String DOCUMENT_BUILDER_FACTORY_FEATURE
- See Also:
- Constant Field Values
-
defaultCharset
public static String defaultCharset
-
-
Constructor Detail
-
XmlConverter
public XmlConverter()
-
XmlConverter
public XmlConverter(DocumentBuilderFactory documentBuilderFactory)
-
-
Method Detail
-
defaultOutputProperties
public Properties defaultOutputProperties()
Returns the default set of output properties for conversions.
-
toResult
public void toResult(Source source, Result result) throws TransformerException
Converts the given input Source into the required result- Throws:
TransformerException
-
toResult
public void toResult(Source source, Result result, Properties outputProperties) throws TransformerException
Converts the given input Source into the required result- Throws:
TransformerException
-
toBoolean
@Converter public Boolean toBoolean(NodeList list)
Converts the given NodeList to a boolean
-
toBytesSource
@Converter public BytesSource toBytesSource(byte[] data)
Converts the given byte[] to a Source
-
toStringSource
@Converter public StringSource toStringSource(String data)
Converts the given String to a Source
-
toDOMSource
@Converter public DOMSource toDOMSource(Node node) throws ParserConfigurationException, TransformerException
Converts the given Node to a Source
-
toDOMSource
@Converter public DOMSource toDOMSource(Document document)
Converts the given Document to a DOMSource
-
toString
@Converter public String toString(Source source, org.apache.camel.Exchange exchange) throws TransformerException
Converts the given input Source into text- Throws:
TransformerException
-
toByteArray
@Converter public byte[] toByteArray(Source source, org.apache.camel.Exchange exchange) throws TransformerException
Converts the given input Source into bytes- Throws:
TransformerException
-
toString
@Converter public String toString(Node node, org.apache.camel.Exchange exchange) throws TransformerException
Converts the given input Node into text- Throws:
TransformerException
-
toStringFromDocument
public String toStringFromDocument(Document document, Properties outputOptions) throws TransformerException
Converts the given Document to into text- Parameters:
document- The document to convertoutputOptions- TheOutputKeysproperties to control various aspects of the XML output- Returns:
- The string representation of the document
- Throws:
TransformerException
-
toDOMSource
@Converter public DOMSource toDOMSource(Source source, org.apache.camel.Exchange exchange) throws ParserConfigurationException, IOException, SAXException, TransformerException
Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toDOMSource
@Converter public DOMSource toDOMSource(String text) throws ParserConfigurationException, IOException, SAXException, TransformerException
Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toDOMSource
@Converter public DOMSource toDOMSource(byte[] bytes) throws IOException, SAXException, ParserConfigurationException
Converts the source instance to aDOMSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toSAXSource
@Converter public SAXSource toSAXSource(String source, org.apache.camel.Exchange exchange) throws IOException, SAXException, TransformerException
Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toStAXSource
@Converter public StAXSource toStAXSource(String source, org.apache.camel.Exchange exchange) throws XMLStreamException
Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).- Throws:
XMLStreamException
-
toStAXSource
@Converter public StAXSource toStAXSource(byte[] in, org.apache.camel.Exchange exchange) throws XMLStreamException
Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).- Throws:
XMLStreamException
-
toSAXSource
@Converter public SAXSource toSAXSource(InputStream source, org.apache.camel.Exchange exchange) throws IOException, SAXException, TransformerException
Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toSAXSource
@Converter public SAXSource toSAXSource(byte[] in, org.apache.camel.Exchange exchange) throws IOException, SAXException, TransformerException
Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toStAXSource
@Converter public StAXSource toStAXSource(InputStream source, org.apache.camel.Exchange exchange) throws XMLStreamException
Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).- Throws:
XMLStreamException
-
toSAXSource
@Converter public SAXSource toSAXSource(File file, org.apache.camel.Exchange exchange) throws IOException, SAXException, TransformerException
Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toStAXSource
@Converter public StAXSource toStAXSource(File file, org.apache.camel.Exchange exchange) throws FileNotFoundException, XMLStreamException
Converts the source instance to aStAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toSAXSource
@Converter public SAXSource toSAXSource(Source source, org.apache.camel.Exchange exchange) throws IOException, SAXException, TransformerException
Converts the source instance to aSAXSourceor returns null if the conversion is not supported (making it easy to derive from this class to add new kinds of conversion).
-
toStreamSource
@Converter public StreamSource toStreamSource(Source source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toStreamSource
@Converter public StreamSource toStreamSource(InputStream in) throws TransformerException
- Throws:
TransformerException
-
toStreamSource
@Converter public StreamSource toStreamSource(Reader in) throws TransformerException
- Throws:
TransformerException
-
toStreamSource
@Converter public StreamSource toStreamSource(File in) throws TransformerException
- Throws:
TransformerException
-
toStreamSource
@Converter public StreamSource toStreamSource(byte[] in, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toStreamSource
@Converter public StreamSource toStreamSource(ByteBuffer in, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toStreamSourceFromSAX
@Converter public StreamSource toStreamSourceFromSAX(SAXSource source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toStreamSourceFromDOM
@Converter public StreamSource toStreamSourceFromDOM(DOMSource source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toStreamSourceFromStAX
@Converter public StreamSource toStreamSourceFromStAX(StAXSource source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toSAXSourceFromStream
@Converter public SAXSource toSAXSourceFromStream(StreamSource source, org.apache.camel.Exchange exchange) throws SAXException
- Throws:
SAXException
-
toReaderFromSource
@Converter public Reader toReaderFromSource(Source src, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toDOMSource
@Converter public DOMSource toDOMSource(InputStream is, org.apache.camel.Exchange exchange) throws ParserConfigurationException, IOException, SAXException
-
toDOMSource
@Converter public DOMSource toDOMSource(File file, org.apache.camel.Exchange exchange) throws ParserConfigurationException, IOException, SAXException
-
toDOMSourceFromStream
@Converter public DOMSource toDOMSourceFromStream(StreamSource source, org.apache.camel.Exchange exchange) throws ParserConfigurationException, IOException, SAXException
-
toSAXSourceFromDOM
@Converter public SAXSource toSAXSourceFromDOM(DOMSource source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toSAXSourceFromStAX
@Converter public SAXSource toSAXSourceFromStAX(StAXSource source, org.apache.camel.Exchange exchange) throws TransformerException
- Throws:
TransformerException
-
toDOMSourceFromSAX
@Converter public DOMSource toDOMSourceFromSAX(SAXSource source) throws IOException, SAXException, ParserConfigurationException, TransformerException
-
toDOMSourceFromStAX
@Converter public DOMSource toDOMSourceFromStAX(StAXSource source) throws IOException, SAXException, ParserConfigurationException, TransformerException
-
toDOMNodeFromSAX
@Converter public Node toDOMNodeFromSAX(SAXSource source) throws ParserConfigurationException, IOException, SAXException, TransformerException
-
toDOMNodeFromStAX
@Converter public Node toDOMNodeFromStAX(StAXSource source) throws ParserConfigurationException, IOException, SAXException, TransformerException
-
toDOMNodeFromSingleNodeList
@Converter(allowNull=true) public Node toDOMNodeFromSingleNodeList(NodeList nl)
Convert a NodeList consisting of just 1 node to a DOM Node.- Parameters:
nl- the NodeList- Returns:
- the DOM Node
-
toDOMDocumentFromSingleNodeList
@Converter(allowNull=true) public Document toDOMDocumentFromSingleNodeList(NodeList nl) throws ParserConfigurationException, TransformerException
Convert a NodeList consisting of just 1 node to a DOM Document. Cannot convert NodeList with length > 1 because they require a root node.- Parameters:
nl- the NodeList- Returns:
- the DOM Document
- Throws:
ParserConfigurationExceptionTransformerException
-
toDOMNode
@Converter(allowNull=true) public Node toDOMNode(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException
Converts the given TRaX Source into a W3C DOM node
-
toDOMElement
@Converter public Element toDOMElement(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException
Create a DOM element from the given source.
-
toDOMElement
@Converter public Element toDOMElement(Node node) throws TransformerException
Create a DOM element from the DOM node. Simply cast if the node is an Element, or return the root element if it is a Document.- Throws:
TransformerException
-
toDOMDocument
@Converter public Document toDOMDocument(byte[] data, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the given data to a DOM document- Parameters:
data- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(InputStream in, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the givenInputStreamto a DOM document- Parameters:
in- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(Reader in, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the givenReaderto a DOM document- Parameters:
in- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(InputSource in, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the givenInputSourceto a DOM document- Parameters:
in- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(String text, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the givenStringto a DOM document- Parameters:
text- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(File file, org.apache.camel.Exchange exchange) throws IOException, SAXException, ParserConfigurationException
Converts the givenFileto a DOM document- Parameters:
file- is the data to be parsedexchange- is the exchange to be used when calling the converter- Returns:
- the parsed document
- Throws:
IOExceptionSAXExceptionParserConfigurationException
-
toDOMDocument
@Converter public Document toDOMDocument(Source source) throws TransformerException, ParserConfigurationException, IOException, SAXException
Create a DOM document from the given source.
-
toDOMDocument
@Converter public Document toDOMDocument(Node node) throws ParserConfigurationException, TransformerException
Create a DOM document from the given Node. If the node is an document, just cast it, if the node is an root element, retrieve its owner element or create a new document and import the node.
-
toInputStream
@Converter public InputStream toInputStream(DOMSource source, org.apache.camel.Exchange exchange) throws TransformerException, IOException
- Throws:
TransformerExceptionIOException
-
toInputStream
@Converter public InputStream toInputStream(Document dom, org.apache.camel.Exchange exchange) throws TransformerException, IOException
- Throws:
TransformerExceptionIOException
-
toInputSource
@Converter public InputSource toInputSource(InputStream is, org.apache.camel.Exchange exchange)
-
toInputSource
@Converter public InputSource toInputSource(File file, org.apache.camel.Exchange exchange) throws FileNotFoundException
- Throws:
FileNotFoundException
-
getDocumentBuilderFactory
public DocumentBuilderFactory getDocumentBuilderFactory()
-
setDocumentBuilderFactory
public void setDocumentBuilderFactory(DocumentBuilderFactory documentBuilderFactory)
-
getTransformerFactory
public TransformerFactory getTransformerFactory()
-
setTransformerFactory
public void setTransformerFactory(TransformerFactory transformerFactory)
-
setupFeatures
protected void setupFeatures(DocumentBuilderFactory factory)
-
getDocumentBuilderFactory
public DocumentBuilderFactory getDocumentBuilderFactory(org.apache.camel.Exchange exchange)
-
createDocumentBuilderFactory
public DocumentBuilderFactory createDocumentBuilderFactory()
-
createDocumentBuilder
public DocumentBuilder createDocumentBuilder() throws ParserConfigurationException
- Throws:
ParserConfigurationException
-
createDocumentBuilder
public DocumentBuilder createDocumentBuilder(DocumentBuilderFactory factory) throws ParserConfigurationException
- Throws:
ParserConfigurationException
-
createDocument
public Document createDocument() throws ParserConfigurationException
- Throws:
ParserConfigurationException
-
createTransformer
public Transformer createTransformer() throws TransformerConfigurationException
-
createTransformerFactory
public TransformerFactory createTransformerFactory()
-
configureSaxonTransformerFactory
public void configureSaxonTransformerFactory(TransformerFactory factory)
Make a Saxon TransformerFactory more JAXP compliant by configuring it to send <xsl:message> output to the ErrorListener.- Parameters:
factory- the TransformerFactory
-
createSAXParserFactory
public SAXParserFactory createSAXParserFactory()
-
-