1

I'am using Configuration 1.6.

I hava a xml file, like

<property>
    <name>sql</name>
    <value><![CDATA[select a, b from c]]></value>
</property>

I wish to get "select a, b from c" as a whole string, but i get "select a" and "b from c" as List instead.

You may suggest I join the string's with commas, but somewhere else in my project depends on this property.

Rostislav Matl
  • 4,294
  • 4
  • 29
  • 53
qiuxiafei
  • 5,827
  • 5
  • 30
  • 43

2 Answers2

0

Change the property of PropertiesConfiguration object like this:

AbstractConfiguration.setListDelimiter(0);

Setting the delimiter to 0 will disable value splitting completely.

That should work.

Phani
  • 5,319
  • 6
  • 35
  • 43
  • What does this mean? If i remove the CDATA flag, i will still get the value as List – qiuxiafei Apr 16 '12 at 09:13
  • Nope. It shouldn't. You are trying to fetch the value of property. It wouldn't give you separated by comma or space without being explicitly mentioned. – Phani Apr 16 '12 at 09:15
  • I don't think so. I think the Configuration will provide you with List no matter if you put the value in CDATA or NOT. – qiuxiafei Apr 16 '12 at 09:21
  • We will get to know if we execute right.Could you try that and post your reply? – Phani Apr 16 '12 at 09:23
  • I see what you are saying. Please find edits for modifications. – Phani Apr 16 '12 at 09:28
0

Using commons configuration 1.9 it is recommend to use:

    config = new XMLConfiguration();
    config.setListDelimiter((char) 0);
    config.setDelimiterParsingDisabled(true);
    config.setAttributeSplittingDisabled(true);
    config.load(resource);
epeleg
  • 10,347
  • 17
  • 101
  • 151