  | Mailing List | | Home | | Forum Home | | JBoss - Java Application Server | | Tomcat - JSP/Servlet container | | Struts - A MVC web framework | | iText - An open source PDF Java Library | | JDOM - JDOM XML Parser | | JSP - A mailing list about Java Server Pages specification and reference | | J2EE - A mailing list for Java(tm) 2 Platform, Enterprise Edition | | J2EE Pattern - An interest list for Sun Java Center J2EE Pattern Catalog | | Servlet - A mailing list for discussion about Sun Microsystem's Java Servlet API Technology | |
Struts & Hibernate
|
|
|
  | | | Commenting whole Elements? | Commenting whole Elements? 2007-12-06 - By Grzegorz Kaczor
Back Hi,
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.
Regards, Grzegorz
2007/12/6, Jan Brauer <jan.brauer@(protected)>: > > 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("<--") > resolves to: > > "&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@(protected) >
-- "Cho? tyle wiemy w?asnym do?wiadczeniem: W nas jest Raj, Piek?o - i do obu - szlaki." J.K.
Hi,<br><br>I believe you should not disable escaping when outputting XML file. It is fine it is working :). <br><br>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. <br><br>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.<br><br>Regards,<br> Grzegorz<br><br><div><span class="gmail_quote">2007/12/6, Jan Brauer <<a href="mailto:jan.brauer@(protected)">jan.brauer@(protected)</a>>:</span> <blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204) ; margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;"> Hi,<br><br>I'm currently writing a tool to merge different fragments into a <br>web.xml. I'm looking for a way to surround an element with comments.<br >I've added a namespaced attribute to the element. Based on this I'm <br>trying to surround the Element with two Text elements:<br><br>Text intro = new Text("<!--");<br>Text outro = new Text("-->");<br ><br>Unfortunately the pointy brackets are escaped. I haven't found a way to <br>disable the escaping:<br><br>new Text("&lt;--")<br>resolves to:<br><br>"&amp;lt;--"<br><br>What can I do to disable the escaping for those two Text elements? Or is<br>there an even better way to accomplish what I'm trying? <br><br>Thx,<br>Jan<br><br><br><br>__ ____ ____ ____ ____ ____ ____ ____ ______ ___<br>To control your jdom-interest membership:<br><a href="http://www.jdom.org /mailman/options/jdom-interest/youraddr@(protected)">http://www.jdom.org /mailman/options/jdom-interest/youraddr@(protected) </a><br></blockquote></div><br><br clear="all"><br>-- <br>"Cho? tyle wiemy w?asnym do?wiadczeniem:<br>W nas jest Raj, Piek?o - i do obu - szlaki."<br >J.K.
__ ____ ____ ____ ____ ____ ____ ____ ____ ____ To control your jdom-interest membership: http://www.jdom.org/mailman/options/jdom-interest/youraddr@(protected)
|
|
 |