[jdom-interest] XML formatting and java class hierarchy

Ludvig Omholt ludde-jdom at restamus.se
Fri Mar 30 04:49:08 PST 2001

On Fri, 30 Mar 2001, Ken Rune Helland wrote:

> At 02:09 PM 3/30/2001 +0200, Ludvig Omholt wrote:
> >Hi!
> >
> >I am using the jdom beta6 (XMLOutputter) to send simple XML messages to a
> >server. The server, however, can't parse the "<![CDATA[" and "]]" strings.
> >I have contacted the folks who implemented the server and questioned their
> >parsing. They have not answered my email yet.
> >
> >In the meantime I would like to fix this by subclassing the org.jdom.CDATA
> >class and override the getSerializedForm() method having it return the
> >getText() String instead. This is not possible because the
> >getSerializedForm() method is final and also there is no interface to
> >implement. Why must the getSerializedForm() method be final? This seems to
> >me to be quite dumb since it limits the use of the library.
> >
> >For now I have resolved the issue by modifying my copy of jdom, but it
> >would be nice to use an "off the shelf" version of the library and create
> >my own subclass of CDATA since that is much cleaner and I don't have to
> >distribute my own version of the jdom JAR.
> >
> >Thanks for any feedback!
> >
> >/Ludde
> If you want it output as text witout the CDATA tags add it as
> a String not as a CDATA object.

Thanks, I had overlooked that one. Works like a charm!

> Or maybe I completly misundestood your problem.

Well, this definitely solves my problem. But it is a workaround. The nice
way in java to do this is to make my own subclass and that can't be done
because the method is final.


  _   _ _ __  __  ___
 | | | | |  \|  \| __| Ludvig Omholt ................. ludde at restamus.se
 | |_| | | D | D | _|  070-310 08 71 ........... http://www.restamus.se/
 |___|___|__/|__/|___| ++++++++ cliff: Linux 2.2.13 on an i686 +++++++++

More information about the jdom-interest mailing list