Technical Notes

My online notepad

  • Social


  • Support

    Donate towards my web hosting bill!

Archive for February, 2015

How to Use CDATA in Spring Configuration Entries

Posted by Anton Khitrenovich on February 15, 2015

Today I had to create a map in Spring XML configuration file, where both keys and values ought to be XML elements by their own. Obviously, using CDATA is the most readable way to achieve that – but it was not immediately clear how to use CDATA for entry’s key and value attributes.

Here is what I ended with:

<util:map id="patterns">
  <entry>
    <key><value><![CDATA[<original>old-value</original>]]></value></key>
    <value><![CDATA[<replacement>new-value</replacement>]]></value>
  </entry>
</util:map>

Enjoy!

Posted in HOWTO | Tagged: , , | Leave a Comment »