CDATA Attributes in java.util.prefs.Preferences
Anyone know why CDATA contents don't seem to work as a value in a key/value pair with java.util.prefs.Preferences? I'm using jdk1.4.2. It would be _really_ nice to allow embedded XML
via a mechanism like:
<node name="MyNodeName">
<map>
<entry key="aSpecificKey" value='<![CDATA[This <begin>is a test</begin> string]]>' />
</map>
</node>
but the parser chokes on this. [Note: yes, I do know that I can use the "put" method followed by the exportSubtree to get the XML encoded in a manner that is digestable by Preferences. However, this isn't very useful as I was planning another, GUI-based, means of creating the XML, so CDATA seemed like a natural fit...]
[777 byte] By [
jgamache] at [2007-9-30 16:09:08]

You don't need the CDATA stuffed in that way. CDATA is part of the dtd description at http://java.sun.com/j2se/1.5.0/docs/api/java/util/prefs/Preferences.html
You would write the xml like:
<node name="MyNodeName">
<map>
<entry key="aSpecificKey" value="is a test" />
</map>
</node>
You code use an XML editor with validation turned on. to check the xml as you go.
but there is no embedded XML in the what you wrote. Without embedded XML, I concur everything works fine. Admittedly, my example was quite lame - but it has an embedded <begin> </begin> tag in it. I don't want the SAX parser that Preferences uses to try to process these tags as they are for use by my application...
Yes, with no other obvious approach, that was what I did.However, do you or anyone know _why_ CDATA does not work?