org.apache.camel.builder.xml
Class XsltBuilder

java.lang.Object
  extended by org.apache.camel.builder.xml.XsltBuilder
All Implemented Interfaces:
Processor

public class XsltBuilder
extends Object
implements Processor

Creates a Processor which performs an XSLT transformation of the IN message body.

Will by default output the result as a String. You can chose which kind of output you want using the outputXXX methods.

Version:

Constructor Summary
XsltBuilder()
           
XsltBuilder(Templates templates)
           
 
Method Summary
protected  void addParameters(Transformer transformer, Map<String,Object> map)
           
 XsltBuilder allowStAX()
          Enables to allow using StAX.
protected  void configureTransformer(Transformer transformer, Exchange exchange)
          Configures the transformer with exchange specific parameters
 XsltBuilder deleteOutputFile()
          Should the output file be deleted when the Exchange is done.
 XmlConverter getConverter()
           
 ErrorListener getErrorListener()
           
 Map<String,Object> getParameters()
           
 ResultHandlerFactory getResultHandlerFactory()
           
protected  Source getSource(Exchange exchange, Object body)
          Converts the inbound body to a Source, if the body is not already a Source.
 Templates getTemplate()
           
 URIResolver getUriResolver()
           
 boolean isAllowStAX()
           
 boolean isDeleteOutputFile()
           
 boolean isFailOnNullBody()
           
protected  boolean isInputStreamNeeded(Exchange exchange)
          Checks whether we need an InputStream to access the message body.
 XsltBuilder outputBytes()
          Sets the output as being a byte[]
 XsltBuilder outputDOM()
          Sets the output as being a DOM
 XsltBuilder outputFile()
          Sets the output as being a File where the filename must be provided in the Exchange.XSLT_FILE_NAME header.
 XsltBuilder outputString()
          Sets the output as being a String
 XsltBuilder parameter(String name, Object value)
           
 void process(Exchange exchange)
          Processes the message exchange
 void setAllowStAX(boolean allowStAX)
           
 void setConverter(XmlConverter converter)
           
 void setDeleteOutputFile(boolean deleteOutputFile)
           
 void setErrorListener(ErrorListener errorListener)
           
 void setFailOnNullBody(boolean failOnNullBody)
           
 void setParameters(Map<String,Object> parameters)
           
 void setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory)
           
 void setTemplate(Templates template)
           
 void setTransformerFile(File xslt)
          Sets the XSLT transformer from a File
 void setTransformerInputStream(InputStream in)
          Sets the XSLT transformer from the given input stream
 void setTransformerSource(Source source)
          Sets the XSLT transformer from a Source
 void setTransformerURL(URL url)
          Sets the XSLT transformer from a URL
 void setUriResolver(URIResolver uriResolver)
           
 String toString()
           
 XsltBuilder transformerCacheSize(int numberToCache)
           
 XsltBuilder uriResolver(URIResolver uriResolver)
          Sets a custom URI resolver to be used
static XsltBuilder xslt(File xslt)
          Creates an XSLT processor using the given XSLT source
static XsltBuilder xslt(InputStream xslt)
          Creates an XSLT processor using the given XSLT source
static XsltBuilder xslt(Source xslt)
          Creates an XSLT processor using the given XSLT source
static XsltBuilder xslt(Templates templates)
          Creates an XSLT processor using the given templates instance
static XsltBuilder xslt(URL xslt)
          Creates an XSLT processor using the given XSLT source
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

XsltBuilder

public XsltBuilder()

XsltBuilder

public XsltBuilder(Templates templates)
Method Detail

toString

public String toString()
Overrides:
toString in class Object

process

public void process(Exchange exchange)
             throws Exception
Description copied from interface: Processor
Processes the message exchange

Specified by:
process in interface Processor
Parameters:
exchange - the message exchange
Throws:
Exception - if an internal processing error has occurred.

xslt

public static XsltBuilder xslt(Templates templates)
Creates an XSLT processor using the given templates instance


xslt

public static XsltBuilder xslt(Source xslt)
                        throws TransformerConfigurationException
Creates an XSLT processor using the given XSLT source

Throws:
TransformerConfigurationException

xslt

public static XsltBuilder xslt(File xslt)
                        throws TransformerConfigurationException
Creates an XSLT processor using the given XSLT source

Throws:
TransformerConfigurationException

xslt

public static XsltBuilder xslt(URL xslt)
                        throws TransformerConfigurationException,
                               IOException
Creates an XSLT processor using the given XSLT source

Throws:
TransformerConfigurationException
IOException

xslt

public static XsltBuilder xslt(InputStream xslt)
                        throws TransformerConfigurationException,
                               IOException
Creates an XSLT processor using the given XSLT source

Throws:
TransformerConfigurationException
IOException

outputBytes

public XsltBuilder outputBytes()
Sets the output as being a byte[]


outputString

public XsltBuilder outputString()
Sets the output as being a String


outputDOM

public XsltBuilder outputDOM()
Sets the output as being a DOM


outputFile

public XsltBuilder outputFile()
Sets the output as being a File where the filename must be provided in the Exchange.XSLT_FILE_NAME header.


deleteOutputFile

public XsltBuilder deleteOutputFile()
Should the output file be deleted when the Exchange is done.

This option should only be used if you use outputFile() as well.


parameter

public XsltBuilder parameter(String name,
                             Object value)

uriResolver

public XsltBuilder uriResolver(URIResolver uriResolver)
Sets a custom URI resolver to be used


allowStAX

public XsltBuilder allowStAX()
Enables to allow using StAX.

When enabled StAX is preferred as the first choice as Source.


transformerCacheSize

public XsltBuilder transformerCacheSize(int numberToCache)

getParameters

public Map<String,Object> getParameters()

setParameters

public void setParameters(Map<String,Object> parameters)

setTemplate

public void setTemplate(Templates template)

getTemplate

public Templates getTemplate()

isFailOnNullBody

public boolean isFailOnNullBody()

setFailOnNullBody

public void setFailOnNullBody(boolean failOnNullBody)

getResultHandlerFactory

public ResultHandlerFactory getResultHandlerFactory()

setResultHandlerFactory

public void setResultHandlerFactory(ResultHandlerFactory resultHandlerFactory)

isAllowStAX

public boolean isAllowStAX()

setAllowStAX

public void setAllowStAX(boolean allowStAX)

setTransformerSource

public void setTransformerSource(Source source)
                          throws TransformerConfigurationException
Sets the XSLT transformer from a Source

Parameters:
source - the source
Throws:
TransformerConfigurationException - is thrown if creating a XSLT transformer failed.

setTransformerFile

public void setTransformerFile(File xslt)
                        throws TransformerConfigurationException
Sets the XSLT transformer from a File

Throws:
TransformerConfigurationException

setTransformerURL

public void setTransformerURL(URL url)
                       throws TransformerConfigurationException,
                              IOException
Sets the XSLT transformer from a URL

Throws:
TransformerConfigurationException
IOException

setTransformerInputStream

public void setTransformerInputStream(InputStream in)
                               throws TransformerConfigurationException,
                                      IOException
Sets the XSLT transformer from the given input stream

Throws:
TransformerConfigurationException
IOException

getConverter

public XmlConverter getConverter()

setConverter

public void setConverter(XmlConverter converter)

getUriResolver

public URIResolver getUriResolver()

setUriResolver

public void setUriResolver(URIResolver uriResolver)

isDeleteOutputFile

public boolean isDeleteOutputFile()

setDeleteOutputFile

public void setDeleteOutputFile(boolean deleteOutputFile)

getErrorListener

public ErrorListener getErrorListener()

setErrorListener

public void setErrorListener(ErrorListener errorListener)

isInputStreamNeeded

protected boolean isInputStreamNeeded(Exchange exchange)
Checks whether we need an InputStream to access the message body.

Depending on the content in the message body, we may not need to convert to InputStream.

Parameters:
exchange - the current exchange
Returns:
true to convert to InputStream beforehand converting to Source afterwards.

getSource

protected Source getSource(Exchange exchange,
                           Object body)
Converts the inbound body to a Source, if the body is not already a Source.

This implementation will prefer to source in the following order:


configureTransformer

protected void configureTransformer(Transformer transformer,
                                    Exchange exchange)
Configures the transformer with exchange specific parameters


addParameters

protected void addParameters(Transformer transformer,
                             Map<String,Object> map)


Apache CAMEL