...
The "outTransformElements", "inTransformElements", "outDropElements", "inDropElements", "outAppendElements", "inAppendElements" and "attributesAsElements" properties can be used.
On the outbound service side, some of the transformation features (e.g. "outTransformElements", "outDropElements") may not work properly prior to CXF versions 3.2.6 and 3.1.17. This is due to outputstream optimization that CXF does. In this case, the outputstream optimization must be explicitly disabled for the outbound transformation feature to work properly by setting the JAX-WS/JAX-RS property "disable.outputstream.optimization" to "true".
Spring configuration
Changing input and output element names and namespaces
...
Code Block | ||||
---|---|---|---|---|
| ||||
<bean id="transformFeature" class="org.apache.cxf.feature.StaxTransformFeature"> <property name="inAppendElements"> <map> <!-- append new simple "thebook" element with a text value '2' before "the "book" element --> <entry key="book" value="thebook=2"/> </map> </property> </bean> |
...
Code Block | ||||
---|---|---|---|---|
| ||||
<bean id="transformFeature" class="org.apache.cxf.feature.StaxTransformFeature"> <property name="inAppendElements"> <map> <!-- append new simple "thebook" element with a text value '2' using afterthe "/" convention as the book", using a '/' convention last child element within the "book" element --> <entry key="book/" value="thebook=2"/> </map> </property> </bean> |
Comparing four append modes
input | append-pre-wrap
| append-post-wrap | append-pre-include | append-post-include |
---|---|---|---|---|
key="book" value="thebook" | key="book/" value="thebook" | key="book" value="thebook=2" | key="book/" value="thebook=2" | |
<sales> | <sales> | <sales> | <sales> | <sales> |
Replacing text content
It's possible to replace the text content of a given simple element only on the input and output, for example:
...