Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

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
xml
xml
<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
xml
xml
<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-wrapappend-pre-includeappend-post-include
 key="book" value="thebook"key="book/" value="thebook"key="book" value="thebook=2"key="book/" value="thebook=2"
<sales>
<book>
<title>CXF ...</title>
<price>38.68</price>
</book>
</sales>
<sales>
<thebook>
<book>
<title>CXF ...</title>
<price>38.68</price>
</book>
</thebook>
</sales>
<sales>
<book>
<thebook>
<title>CXF ...</title>
<price>38.68</price>
</thebook>
</book>
</sales>
<sales>
<thebook>2</thebook>
<book>
<title>CXF ...</title>
<price>38.68</price>
</book>
</sales>
<sales>
<book>
<title>CXF ...</title>
<price>38.68</price>
<thebook>2</thebook>
</book>
</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:

...