2. Enterprise Integration Patterns

xmlContentFilter

The xmlContentFilter removes certain XML elements from message bodies. The elements are described using an XPath expression.


<h3>Explanation:</h3>

If the XPath expression is simple enough, a StAX-Parser is used to determine whether the XPath might match a message at all. This can improve performance significantly, as a DOM tree does probably not have to to be constructed for every message. This is, for example, the case in <listing name="example"> <src lang="xml"> <xmlContentFilter xPath="//*[local-name()='Fault' and namespace-uri()='http://schemas.xmlsoap.org/soap/envelope/']//*[local-name()='stacktrace']" /> </src> <caption>xmlContentFilter using a StAX-Parser for improved performance</caption> </listing> where the existence of the <Fault>-element is checked using the StAX-parser before the DOM is constructed.

If the message body is not well-formed XML, it is left unchanged. If the message is XOP-encoded, the XPath-expression is run on the reconstituted message; if it matches, the message is replaced by the modified reconstituted message.


Can be used in:

serviceProxy, api, proxy, global, chainDef, for, choose, stompProxy, if, registration, wsStompReassembler, internal, interceptor, chain, bean, transport and soapProxy

Syntax

<xmlContentFilter xPath="string" />

Sample

<proxies>
  <serviceProxy port="2000">
	<response>
	  <xmlContentFilter xPath="//book/reviews" />
	</response>

	<target host="www.membrane-soa.org" />
  </serviceProxy>
</proxies>

Attributes

NameRequiredDefaultDescriptionExample
xPath true - An XPath 1.0 expression describing the elements to be removed from message bodies.
-