[jdom-interest] Commenting whole Elements?

Grzegorz Kaczor grzegorz.kaczor at gmail.com
Thu Dec 6 03:21:07 PST 2007


I believe you should not disable escaping when outputting XML file. It is
fine it is working :).

I would serialize the element to ByteArrayOutputStream using XMLOutputter,
then create a string out of it and add a Comment element with the serialized
form of your element as its text.

The only drawback of this solution is that your element will have namespace
declarations inside. From the view of XML infoset this is not a problem - it
will be working if someone uncomments it.


2007/12/6, Jan Brauer <jan.brauer at coremedia.com>:
> Hi,
> I'm currently writing a tool to merge different fragments into a
> web.xml. I'm looking for a way to surround an element with comments.
> I've added a namespaced attribute to the element. Based on this I'm
> trying to surround the Element with two Text elements:
> Text intro = new Text("<!--");
> Text outro = new Text("-->");
> Unfortunately the pointy brackets are escaped. I haven't found a way to
> disable the escaping:
> new Text("&lt;--")
> resolves to:
> "&amp;lt;--"
> What can I do to disable the escaping for those two Text elements? Or is
> there an even better way to accomplish what I'm trying?
> Thx,
> Jan
> _______________________________________________
> To control your jdom-interest membership:
> http://www.jdom.org/mailman/options/jdom-interest/youraddr@yourhost.com

"Choć tyle wiemy własnym doświadczeniem:
W nas jest Raj, Piekło - i do obu - szlaki."
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://www.jdom.org/pipermail/jdom-interest/attachments/20071206/276e9c48/attachment.htm

More information about the jdom-interest mailing list