Package org.frankframework.senders
Class XsltSender
java.lang.Object
org.frankframework.senders.AbstractSender
org.frankframework.senders.AbstractSenderWithParameters
org.frankframework.senders.XsltSender
- All Implemented Interfaces:
IConfigurable
,IConfigurationAware
,INamedObject
,IScopeProvider
,ISender
,ISenderWithParameters
,IWithParameters
,IThreadCreator
,org.springframework.beans.factory.Aware
,org.springframework.context.ApplicationContextAware
- Direct Known Subclasses:
JsonXsltSender
Perform an XSLT transformation with a specified stylesheet or XPath-expression.
- Since:
- 4.9
- Author:
- Gerrit van Brakel
- Parameters
- any parameters defined on the sender will be applied to the created transformer
-
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
static final boolean
protected ThreadLifeCycleEventListener<Object>
protected IThreadConnectableTransactionManager
Fields inherited from class org.frankframework.senders.AbstractSenderWithParameters
parameterNamesMustBeUnique, paramList
Fields inherited from class org.frankframework.senders.AbstractSender
log
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Theconfigure()
method instantiates a transformer for the specified XSL.protected ContentHandler
createHandler
(Message input, ThreadConnector<Object> threadConnector, PipeLineSession session, TransformerPool poolToUse, ContentHandler handler, MessageBuilder messageBuilder) protected ContentHandler
filterInput
(ContentHandler input, PipeLineSession session) protected TransformerPool
getTransformerPoolToUse
(PipeLineSession session) protected XMLReader
getXmlReader
(PipeLineSession session, ContentHandler handler) int
boolean
protected boolean
isDisableOutputEscaping
(TransformerPool poolToUse) boolean
boolean
boolean
sendMessage
(Message message, PipeLineSession session) alternative implementation of send message, that should do the same as the original, but reuses the streaming content handlervoid
setDebugInput
(boolean debugInput) If settrue
the input is written to the log file, at DEBUG levelvoid
If settrue
, any output is reparsed before being handled as XML again.void
setHandleLexicalEvents
(boolean b) If settrue
, the transformer is enabled to handle lexical events, allowing it for example to process comments and to distinghuish CDATA from escaped text.void
If settrue
, result is pretty-printed.void
setNamespaceDefs
(String namespaceDefs) Namespace defintions for xpathExpression.void
Omit the XML declaration on top of the output.void
For xpathExpression onlyvoid
setRemoveNamespaces
(boolean b) If settrue
namespaces (and prefixes) in the input message are removed before transformationvoid
setSkipEmptyTags
(boolean b) If settrue
empty tags in the output are removed after transformationvoid
setStreamingXslt
(Boolean streamingActive) If true, then this sender will process the XSLT while streaming in a different thread.void
setStyleSheetCacheSize
(int size) Size of cache of stylesheets retrieved from styleSheetNameSessionKeyvoid
setStyleSheetName
(String stylesheetName) Location of stylesheet to apply to the input messagevoid
setStyleSheetNameSessionKey
(String newSessionKey) Session key to retrieve stylesheet location.void
setThreadLifeCycleEventListener
(ThreadLifeCycleEventListener<Object> threadLifeCycleEventListener) void
setTxManager
(IThreadConnectableTransactionManager txManager) void
setXpathExpression
(String string) Alternatively: XPath-expression to create stylesheet fromvoid
setXsltVersion
(int xsltVersion) If set to2
or3
a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan).void
start()
This method will be called to start the sender.void
stop()
Stop/close the sender and deallocate resources.Methods inherited from class org.frankframework.senders.AbstractSenderWithParameters
addParameter, checkStringAttributeOrParameter, consumesSessionVariable, getParameterList, getParameterOverriddenAttributeValue, getParameterOverriddenAttributeValue, getParameterValueList
Methods inherited from class org.frankframework.senders.AbstractSender
createBean, getApplicationContext, getConfigurationClassLoader, getLogPrefix, getName, setApplicationContext, setName
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.springframework.context.ApplicationContextAware
setApplicationContext
Methods inherited from interface org.frankframework.core.IConfigurationAware
getApplicationContext, getName
Methods inherited from interface org.frankframework.core.INamedObject
getName, setName
Methods inherited from interface org.frankframework.core.IScopeProvider
getConfigurationClassLoader
Methods inherited from interface org.frankframework.core.ISender
isSynchronous, sendMessageOrThrow
-
Field Details
-
DEFAULT_OUTPUT_METHOD
-
DEFAULT_XPATH_OUTPUT_METHOD
-
DEFAULT_INDENT
public static final boolean DEFAULT_INDENT- See Also:
-
DEFAULT_OMIT_XML_DECLARATION
public static final boolean DEFAULT_OMIT_XML_DECLARATION- See Also:
-
threadLifeCycleEventListener
-
txManager
-
-
Constructor Details
-
XsltSender
public XsltSender()
-
-
Method Details
-
configure
Theconfigure()
method instantiates a transformer for the specified XSL. If the stylesheetName cannot be accessed, a ConfigurationException is thrown.- Specified by:
configure
in interfaceIConfigurable
- Specified by:
configure
in interfaceISender
- Overrides:
configure
in classAbstractSenderWithParameters
- Throws:
ConfigurationException
-
start
public void start()Description copied from interface:ISender
This method will be called to start the sender. After this method is called the sendMessage method may be called. Purpose of this method is to reduce creating connections to databases etc. in thesendMessage()
method.- Specified by:
start
in interfaceISender
- Overrides:
start
in classAbstractSender
-
stop
public void stop()Description copied from interface:ISender
Stop/close the sender and deallocate resources.- Specified by:
stop
in interfaceISender
- Overrides:
stop
in classAbstractSender
-
filterInput
-
isDisableOutputEscaping
protected boolean isDisableOutputEscaping(TransformerPool poolToUse) throws TransformerException, IOException - Throws:
TransformerException
IOException
-
getTransformerPoolToUse
protected TransformerPool getTransformerPoolToUse(PipeLineSession session) throws SenderException, ConfigurationException -
createHandler
protected ContentHandler createHandler(Message input, ThreadConnector<Object> threadConnector, PipeLineSession session, TransformerPool poolToUse, ContentHandler handler, MessageBuilder messageBuilder) throws TransformerException - Throws:
TransformerException
-
getXmlReader
protected XMLReader getXmlReader(PipeLineSession session, ContentHandler handler) throws ParserConfigurationException, SAXException -
sendMessage
@Nonnull public SenderResult sendMessage(@Nonnull Message message, @Nonnull PipeLineSession session) throws SenderException alternative implementation of send message, that should do the same as the original, but reuses the streaming content handler- Specified by:
sendMessage
in interfaceISender
- Throws:
SenderException
-
setStreamingXslt
If true, then this sender will process the XSLT while streaming in a different thread. Can be used to switch streaming off for debugging purposes- Default value
- set by appconstant xslt.streaming.default
-
setStyleSheetName
Location of stylesheet to apply to the input message -
setStyleSheetNameSessionKey
Session key to retrieve stylesheet location. Overrides stylesheetName or xpathExpression attribute -
setStyleSheetCacheSize
public void setStyleSheetCacheSize(int size) Size of cache of stylesheets retrieved from styleSheetNameSessionKey- Default value
- 100
-
setXpathExpression
Alternatively: XPath-expression to create stylesheet from -
setOmitXmlDeclaration
Omit the XML declaration on top of the output. If not set, the value specified in the stylesheet is followed- Default value
- false, if not set in stylesheet
-
setDisableOutputEscaping
If settrue
, any output is reparsed before being handled as XML again. If not set, the stylesheet is searched for@disable-output-escaping='yes'
and the value is set accordingly- Default value
- false, if not set in stylesheet
-
setNamespaceDefs
Namespace defintions for xpathExpression. Must be in the form of a comma or space separated list ofprefix=namespaceuri
-definitions. For some other use cases (NOT xpathExpression), one entry can be without a prefix, that will define the default namespace. If left empty, an the xpathExpression will match any namespace -
setOutputType
For xpathExpression only- Default value
- text
-
setIndentXml
If settrue
, result is pretty-printed. If not set, the value specified in the stylesheet is followed- Default value
- false, if not set in stylesheet
-
setRemoveNamespaces
public void setRemoveNamespaces(boolean b) If settrue
namespaces (and prefixes) in the input message are removed before transformation- Default value
- false
-
setHandleLexicalEvents
public void setHandleLexicalEvents(boolean b) If settrue
, the transformer is enabled to handle lexical events, allowing it for example to process comments and to distinghuish CDATA from escaped text. Beware that this option can cause spurious NullPointerExceptions due to a race condition in streaming XSLT 1.0 processing in Xalan 2.7.2- Default value
- false
-
setSkipEmptyTags
public void setSkipEmptyTags(boolean b) If settrue
empty tags in the output are removed after transformation- Default value
- false
-
setXsltVersion
public void setXsltVersion(int xsltVersion) If set to2
or3
a Saxon (net.sf.saxon) xslt processor 2.0 or 3.0 respectively will be used, otherwise xslt processor 1.0 (org.apache.xalan).0
will auto-detect- Default value
- 0
-
setDebugInput
public void setDebugInput(boolean debugInput) If settrue
the input is written to the log file, at DEBUG level- Default value
- false
-
getStyleSheetName
-
getStyleSheetNameSessionKey
-
getXpathExpression
-
getNamespaceDefs
-
getOutputType
-
getOmitXmlDeclaration
-
getIndentXml
-
getDisableOutputEscaping
-
isHandleLexicalEvents
public boolean isHandleLexicalEvents() -
isRemoveNamespaces
public boolean isRemoveNamespaces() -
isSkipEmptyTags
public boolean isSkipEmptyTags() -
getXsltVersion
public int getXsltVersion() -
isDebugInput
public boolean isDebugInput() -
setThreadLifeCycleEventListener
public void setThreadLifeCycleEventListener(ThreadLifeCycleEventListener<Object> threadLifeCycleEventListener) - Specified by:
setThreadLifeCycleEventListener
in interfaceIThreadCreator
-
setTxManager
-
getStreamingXslt
-